I am using this Xcode template for core data.
On the delegate, I have this method:
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
but this requires iOS4.
I am trying to make the app compatible with 3.0.
So, I have converted this method to:
- (NSURL *)applicationDocumentsDirectory {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [NSURL URLWithString:documentsDirectory];
}
but when coredata tries to use the store URL on
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MyFile.sqlite"];
if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
it crashes on the IF line with the message:
CoreData SQL stores only support file URLs (got /var/mobile/Applications/BB312A7E-6AE1-4BA2-AD87-6B96D8855CC6/Documents/MyFile.sqlite).’
but StoreURL is a NSURL!
Any clues? Thanks
Try doing:
See if that does the trick.