// Returns the URL to the application's Documents directory.
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
For your example this would return
/var/mobile/Applications/8EFCBF99-BC19-4AFE-934A-B47CBEDF2971/Documents
Does that help you? I think the method is included in the AppDelegate of all Xcode project types that use Core Data.
Here is an example:
NSString *validPath = [[[self applicationDocumentsDirectory] path] stringByAppendingPathComponent:@"test"];
NSString *invalidPath = @"/var/mobile/Applications/abc/test";
if (0 == [validPath rangeOfString:[[self applicationDocumentsDirectory] path]].location) {
// will be executed
NSLog(@"Valid path");
}
else {
NSLog(@"Invalid path");
}
if (0 == [invalidPath rangeOfString:[[self applicationDocumentsDirectory] path]].location) {
NSLog(@"Valid path");
}
else {
// will be executed
NSLog(@"Invalid path");
}