Core Data and NSFetchRequest
Core Data and NSFetchRequest
- Subject: Core Data and NSFetchRequest
- From: Marcus Roberts <email@hidden>
- Date: Wed, 11 May 2005 22:28:29 +0100
I've been working through the Core Data tutorials and documentation on
the Apple site, and they've been very useful. However, I'm stuck at
the moment on using NSFetchRequest.
I've used XCode to design a managed object model and and using Cocoa
Bindings I can very easily create lots of arrays of managed objects,
and have managed objects referencing each other.
However, I now want to access the objects created programmatically.
Through the default "many items" interface and bindings, I have
created a set of managed objects of type Task, which save and restore
to/from the persistent store no problem. What I now want to do is
access those objects, and I think I can get a handle on them by
'fetching' them.
Reading through the NSPersistentDocumentTutorial, it shows how to use
NSFetchRequest, including the following code snippet:
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Department"
inManagedObjectContext:moc];
[fetchRequest setEntity:entity];
fetchResults = [moc executeFetchRequest:fetchRequest error:&fetchError];
but this seems to assume you have previously inserted the object using
something like:
NSEntityDescription insertNewObjectForEntityForName:@"Department"
inManagedObjectContext:managedObjectContext
When I invoke
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Task"
inManagedObjectContext:moc];
I get
"+entityForName: could not locate an NSManagedObjectModel"
Do I need to do something to load the managed object model into the
document - even though it seems to already been in use as the bound
interface is working fine.
Thanks
Marcus
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden