Maybe the title of the question is not very self-explanatory but I don't know how to summ it up.
I'm finishing an App which is basically a DB. I will ship a DB within the App. Everything works well but now I came to the problem. When the App is installed, it needs to create the database on the device. So, I dragged the DB to the "Supporting Files" folder in my Xcode project (still Xcode 4.1, by the way). I went to the AppDelegate.m file and looked for the (NSPersistentStoreCoordinator *)persistentStoreCoordinator{} method.
I substituted the line:
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Database.sqlite"];
for this code:
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Database.sqlite"];
NSLog(@"%@", storePath);
NSURL *storeURL = [NSURL fileURLWithPath:storePath];
// Put down default db if it doesn't already exist
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"Database" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
}
}
I got that from a tutorial by Ray Wenderlich.
The thing is that the compiler gives me a warning on the line
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Database.sqlite"];
that tells me "NSURL may not respond to 'stringByAppendingPathComponent' and, actually, the App crashes because of that. interestingly enough, the example from the tutorial gives no warning whatsoever.
Somebody could give me a hand in what am I missing?
Thanks in advance!