0

I want to be able to save and load documents, so I'm trying to use these methods:

[NSKeyedArchiver archiveRootObject: rootObject toFile: @"myMap.map"];

rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:@"myMap.map"];

What am I meant to put as the file argument? I just have a constant string for now, but that means I can only load one file, I assume there's a way to get the user's selection from the open panel to be the argument, but how?

Mirror318
  • 11,875
  • 14
  • 64
  • 106

2 Answers2

0

Use NSFileManager:

NSArray *allFileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"SomeDirectory"];
0

I found the solution, I now use this method:

[NSKeyedArchiver archivedDataWithRootObject:rootObject];

Which saves data to the file the user choses in the save/load panel. I still don't know how to access the document's path, but this works good enough.

Mirror318
  • 11,875
  • 14
  • 64
  • 106
  • just append the items of the obtained array (from my answer) to the base path. –  Oct 04 '12 at 13:48