• 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
Problem with NSPersistentStore
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with NSPersistentStore


  • Subject: Problem with NSPersistentStore
  • From: Laurent Daudelin <email@hidden>
  • Date: Fri, 15 Feb 2013 16:37:02 -0800

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					email@hidden

_______________________________________________

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: Mike Abdullah <email@hidden>
  • Prev by Date: Re: How to use NSManagedObjectContext, NSManagedObjectModel, NSEntityDescription, NSManagedObject
  • Next by Date: Multiple methods named...
  • Previous by thread: Re: OS X Collection Views videos?
  • Next by thread: Re: Problem with NSPersistentStore
  • Index(es):
    • Date
    • Thread