Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoreData application directory crashes on iOS3

I have nearly finished my application that works well on iOS4, however when loading it into the 3.2 simulator it crashes with..

2010-12-21 07:54:32.052 App[14044:207] *** -[NSPathStore2 URLByAppendingPathComponent:]: unrecognized selector sent to instance 0x4d2b640
2010-12-21 07:54:32.054 App[14044:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPathStore2 URLByAppendingPathComponent:]: unrecognized selector sent to instance 0x4d2b640'

I am getting the application Document Directory with

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"App.sqlite"];

- (NSURL *)applicationDocumentsDirectory {
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

Any help would be great, thanks.

like image 739
SlateEntropy Avatar asked Dec 08 '22 00:12

SlateEntropy


1 Answers

Used

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:@"app.sqlite"];
NSURL *storeURL = [NSURL fileURLWithPath:myPathDocs];

Thanks Justin

like image 57
SlateEntropy Avatar answered Dec 09 '22 14:12

SlateEntropy