0
votes

I am very new to the iPhone development and although I spent hours in searching for the right answer I only got more confused at the end. Here is my question - I'm making a simple iPhone application which has its own database/consisting of only one simple table and being stored in my projects folder along with all the .m and .h files/ and which uses the managed object model presented by core data. I think I did everything the way it should be done but my program ends with the following "Unresolved error Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)

Actually here is the whole output:

2011-12-07 18:50:50.009 weatherForecast[5368:207] CoreData: error: (1) I/O error for database at /Users/eln/Library/Application Support/iPhone Simulator/5.0/Applications/4991C3EB-BDC2-4507-B1FB-720F6DC30245/Documents/weatherForecast.sqlite. SQLite error code:1, 'no such table: Z_METADATA'

2011-12-07 18:50:50.012 weatherForecast[5368:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)" UserInfo=0x6a33e40 {NSUnderlyingException=I/O error for database at /Users/toma.popov/Library/Application Support/iPhone Simulator/5.0/Applications/4991C3EB-BDC2-4507-B1FB-720F6DC30245/Documents/weatherForecast.sqlite. SQLite error code:1, 'no such table: Z_METADATA', NSSQLiteErrorDomain=1}, { NSSQLiteErrorDomain = 1; NSUnderlyingException = "I/O error for database at /Users/eln/Library/Application Support/iPhone Simulator/5.0/Applications/4991C3EB-BDC2-4507-B1FB-720F6DC30245/Documents/weatherForecast.sqlite. **SQLite error code:1, 'no such table: Z_METADATA'";

my program stops right in this get method: **

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil)
    {
        return __persistentStoreCoordinator;
    }
    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"weatherForecast.sqlite"];
   NSLog(@"DATABASE IS LOCATED AT: %@",(NSString *)[self applicationDocumentsDirectory]);
    NSError *error = nil;
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
    {
        //right here my program aborts
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

**

I will be much grateful if someone gives me advise or at least suggestion on what might the problem be.Thank you in advance!

1

1 Answers

1
votes

Core Data needs to manage/create its own database, it can't use one that you've created yourself. Is weatherForecast.sqlite such a file?