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.
While you can't fetch all values of bar, you can certainly fetch
all instances of Foo where bar == someValue. This is what the
predicate you can set on an NSFetchRequest is for. See <http://
Classes/NSFetchRequest.html> and <http://developer.apple.com/
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
I have the fetch request. What I was wanting to do is to call
the fetch request once with each unique value of bar, so that I could
group them that way for an NSOutlineView.
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