문제

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?

도움이 되었습니까?

해결책

Use NSFileManager:

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top