2013-08-02 16 views
0

我與目標C(IOS)和我的工作發現這個代碼:如何在目標C中製作路徑?

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

我想知道archivePath應保存在文件目錄中的文件內容。

謝謝

回答

1

爲了弄清楚archivePath:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
NSUserDomainMask, YES); 
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory 
NSString *archivePath = [documentsPath stringByAppendingPathComponent:@"Person"]; 
+0

謝謝,解決我的問題:d –