I got a few crash reports from users that have a problem with my CoreData app.

Given the following code:

/*
 Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the application's 
store added to it.
 */
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (_persistentStoreCoordinator == nil) {
        NSURL *storeUrl = [NSURL fileURLWithPath:self.persistentStorePath];
        _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
initWithManagedObjectModel:[NSManagedObjectModel mergedModelFromBundles:nil]];
        NSError *error = nil;
        NSPersistentStore *persistentStore = [_persistentStoreCoordinator 
addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl 
options:nil error:&error];
        NSAssert3(persistentStore != nil, @"%s at %d: Unhandled error adding 
persistent store: %@", __FUNCTION__, __LINE__, [error localizedDescription]);
                NSLog(@"Created persistent store '%@' at URL %@", 
persistentStore, storeUrl);
    }
    return _persistentStoreCoordinator;
}

When the MOC tries to perform a save, an exception is generated:

Exception reason

This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a 
save operation.

Stacktrace

PRIMARY THREAD THREAD 0

        • 0 CoreFoundation 0x356212a3 __exceptionPreprocess + 163
        • 1 libobjc.A.dylib 0x3393197f objc_exception_throw + 31
        • 2 CoreData 0x36f2dfef -[NSPersistentStoreCoordinator 
executeRequest:withContext:error:] + 299
        • 3 CoreData 0x36f862d3 -[NSManagedObjectContext save:] + 731

How can the persistent store not being existing? 

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin                                 
http://www.nemesys-soft.com/
Logiciels Nemesys Software                                      
laur...@nemesys-soft.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to