On 16 Feb 2013, at 00:37, Laurent Daudelin <laur...@nemesys-soft.com> wrote:

> 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? 

Well you whacked in some assertions that failures never happen (generally a bad 
idea for disk access. It *is* going to fail sometime). Have those assertions 
fired?


_______________________________________________

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