Reputation: 1129
I'm working with Objective C (IOS) and I found this code:
Person *aPerson = <#Get a Person#>;
NSString *archivePath = <Path for the archive#>;
BOOL success = [NSKeyedArchiver archiveRootObject:aPerson toFile:archivePath];
I would like to know what the archivePath should be to save the file in documents directory.
Thank you
Upvotes: 0
Views: 86
Reputation: 2040
To figure out archivePath:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
NSString *archivePath = [documentsPath stringByAppendingPathComponent:@"Person"];
Upvotes: 1