2013-08-02 2 views
0

Я работаю с Objective 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 –

Смежные вопросы