0

我正在使用Objective C(IOS),我发现了这段代码:

Person *aPerson = <#Get a Person#>;
NSString *archivePath = <Path for the archive#>;
BOOL success = [NSKeyedArchiver archiveRootObject:aPerson toFile:archivePath];

我想知道将文件保存在文档目录中的 archivePath 应该是什么。

谢谢

4

1 回答 1

1

要找出archivePath:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);  
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory 
NSString *archivePath = [documentsPath stringByAppendingPathComponent:@"Person"];
于 2013-08-02T23:54:18.793 回答