Hi I am a begginer with IOS and have created my first core data app. I have created my modal and included it in the project. It does contain the entity 'Client'. When I use the following test code to create the database and attempt to add a Entity I get the following error
..'+entityForName: could not locate an NSManagedObjectModel for entity name 'ItemMake''
when calling [NSEntityDescription insertNewObjectForEntityForName:@"Client" inManagedObjectContext:contxt];
I have checked everything I can think off, the code is shown below. This is some further information...
a) mdl and contxt are not nil.
b) database file is created in the simulator (16kb)
c) accessing the database from another tool shows only two tables which appear to be SQLlite system tables
d) The package does contain a 'EasyOrder.momd' directory and a 'EasyOrder.mom' file. The app is called 'EasyOrder'.
e) The project contains a 'EasyOrder.xcdatamodeld' file which has a Client entity (among others) defined.
f) I have tried other enities in my database with the same results
g) My was a standard app that I added core data support too. I am not using default code in the app delegate, but my examples do not either.
Code as follows
NSManagedObjectContext *contxt;
NSManagedObjectModel *mdl;
NSPersistentStoreCoordinator *ps;
mdl = [NSManagedObjectModel mergedModelFromBundles:nil];
ps = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mdl];
NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [documentDirectories objectAtIndex:0];
NSString *dbLoc = [docDir stringByAppendingPathComponent:@"test.sqllite"];
NSURL *databaseUrl = [NSURL fileURLWithPath:dbLoc];
NSError *err;
if ([ps addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:databaseUrl
options:nil
error:&err] == false) {
NSLog(@"%@", err);
}
[contxt setUndoManager:nil];
//Add record
//CRASHES HERE !
Client *c = [NSEntityDescription insertNewObjectForEntityForName:@"Client" inManagedObjectContext:contxt];
[c setEntityRef:1234];
....
tia Rob