• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with NSPersistentStore
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with NSPersistentStore


  • Subject: Re: Problem with NSPersistentStore
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 16 Feb 2013 10:00:05 +0000

On 16 Feb 2013, at 00:37, Laurent Daudelin <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Problem with NSPersistentStore
      • From: Laurent Daudelin <email@hidden>
References: 
 >Problem with NSPersistentStore (From: Laurent Daudelin <email@hidden>)

  • Prev by Date: Multiple methods named...
  • Next by Date: Re: Multiple methods named...
  • Previous by thread: Problem with NSPersistentStore
  • Next by thread: Re: Problem with NSPersistentStore
  • Index(es):
    • Date
    • Thread