I created a single view application that was running fine, but when I add core data in it just by copying the same code that Xcode generates in Empty Project using Core Data.
But my application crashes by saying that It is unable to create the Persistent Store Coordinator. Applying breakpoints on all exceptions I came to know that my application is crashing on this line
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel];
Before this, I have verified the URL in Managed Object Model. URL is returning NULL.
- (NSManagedObjectModel *)managedObjectModel
{
if (_managedObjectModel != nil) {
return _managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"ProjectName" withExtension:@"momd"];
NSLog(@"Url:%@",modelURL);
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}
I have done all the necessary things to add core data in single view application but using this link Add Core data in Single View Application
Personal perception :: I think something going wrong with URL, as it is returning NULL.
Please Please Help me, I am in great trouble.
Thanks in anticipation