Search code examples
iphoneobjective-cdirectoryfilepathdocuments

Are these two ways of getting the filepath equivalent?


NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[pathArray objectAtIndex:0] stringByAppendingPathComponent:@"data.plist"];

and

return [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];

the file is stored in my documents folder.


Solution

  • No, they are not. The former returns a path to the file named data.plist in the app's Documents directory, the latter returns a path to the file named data.plist in the app's bundle, where all the app's resources, executable, etc are located.