my NSManagedObjectModel is returning nil eventhough the path is correct.
NSString *modelKey = [NSString stringWithFormat:@"/%@/Model", name];
NSString *modelPath = [((Configuration *)[Configuration shared]) stringEntry:modelKey];
NSURL *modelURL = nil;
if ( ! [modelPath contains:@"://"] ) {
modelPath = PathForBundleResource( modelPath );
modelURL = [NSURL fileURLWithPath:modelPath];
}
NSManagedObjectModel *m = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
NSString *PathForBundleResource(NSString *relativePath)
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
return [resourcePath stringByAppendingPathComponent:relativePath];
I've reset the simulator, did a clean build but nothing helped.
I'm new to iPhone programming (core data in particular).
Would appreciate any help.
Edit: I've edited the original post regarding the xcdatamodeld file. It wasn't linked up properly initially but now it is and still having the same problem.
Edit 2: Apparently the name of the xcdatamodel had some variations to the name of the xcdatamodel after linkage. It's working now. Feeling so stupid. Don't know how to delete this question.
I had the same problem after I renamed .xcdatamodeld file. The problem was solved by closing and reopening the Xcode client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With