Re: CoreData - how to retrieve a particular value (not object)
Re: CoreData - how to retrieve a particular value (not object)
- Subject: Re: CoreData - how to retrieve a particular value (not object)
- From: Rick Ballard <email@hidden>
- Date: Fri, 27 May 2005 14:32:38 -0700
On May 27, 2005, at 1:44 PM, T Reaves wrote: If I have object Foo with a variable bar (a string) as an NSManagedObject, is it possible to run a fetch request /query (something) to return a set of all values of bar? Why I want to do this is I want to execute a fetch request to retrieve all instance of Foo where bar == someValue.
So what you want to do is create a fetch request, set its entity to Foo, and set a predicate on it that tests for bar == someValue. Executing this fetch request on a context will return an array of all instances of Foo whose bar == someValue.
Note that you can do this even more easily by creating your fetch request in your data model in Xcode. If you open your data model, select the Foo entity, and add a fetch request, you can use the graphical predicate builder to build the request's predicate. To get that fetch request at runtime so you can tell the context to execute it, you'd invoke -[NSManagedObjectModel fetchRequestFromTemplateWithName:].
- Rick Ballard |
_______________________________________________
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