When the user clicks the + button in the navbar, a UIAlert with text prompt comes up. The user then enters a string into the prompt and it should result in a new UITableViewCel
I'm not seeing where your ManagedObjectContext is declared and hooked into your existing data model. As in, where do you declare your "getter" for accessing it from the persistentStoreCoordinator. Try checking your connection and inserting on viewDidLoad. And check the documentation steps here:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOM.html#//apple_ref/doc/uid/TP40005190-SW1
Here's an example of it hooking into your perstistantStoreCoordinator
- (NSManagedObjectContext *) managedObjectContext {
if (managedObjectContext != nil) {
return managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
managedObjectContext = [[NSManagedObjectContext alloc] init];
[managedObjectContext setPersistentStoreCoordinator: coordinator];
}
return managedObjectContext;
}
Or from the tutorial you're using, you'll see it in the application delegate's didFinishLaunching method :
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
// Handle the error.
}
// Pass the managed object context to the view controller.
rootViewController.managedObjectContext = context;
EDIT
After reviewing your code, you need to do two things :
1) edit your AppDelegate to load the "Curl" model, not the "Temp" model. That's the name of your xdatamodel.
2) You need to reference your app delegate's context and NOT make one locally. I.e.
CurlAppDelegate *curlAppDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [curlAppDelegate managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Routine" inManagedObjectContext:context];
[request setEntity:entity];
NSError *error = nil;
NSMutableArray *mutableFetchResults = [[context executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil) {
// Handle the error.
}
The "NSInternalInconsistencyException" error is related to having changed your underlying data model to the extent that Core Data can't perform an automatic lightweight data migration: the actual SQLite or plist file you're using to store your data is now incompatible with the new structure of the data model.
To clear it up you can either just delete the app from the simulator (or device, if that's where you're testing) the usual way -- pressing and holding the app icon until it wiggles and then tapping/clicking the X -- or by deleting the file itself from the app's working directory on your Mac.
~/Library/Application Support/iPhone Simulator/YOUR-IOS-BASE-SDK-HERE/Applications/YOUR-36-BYTE-APP-ID-HERE/Documents
(Or if not Documents, whichever folder you used.)
After that you can run the app that this particular error will disappear because Core Data will be able to create the file from scratch again.