Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
- Subject: Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
- From: Jim Correia <email@hidden>
- Date: Mon, 20 Apr 2009 14:24:01 -0400
On Apr 20, 2009, at 2:02 PM, Jerry Krinock wrote:
A much better way appears to be to fetch all objects from the store
with no predicate and then use -[NSArray
filteredArrayWithPredicate:]. This takes only one more line of
code, solves all problems, and is supposedly cheaper too:
"If you use the Core Data framework, the array methods provide an
efficient means of filtering an existing array of objects without —-
as a fetch does —- requiring a round trip to a persistent data store."
[...]
Makes me wonder why NSFetchRequest even supports a predicate, since
its predicate has all these limitations and is supposedly more
expensive when compared to fetching all objects and then using -
[NSArray filteredArrayWithPredicate:] ?
You are taking that quote out of context and misinterpreting it.
If you already have an array of NSManagedObjects (fully realized, no
faults), then it is going to be faster to filter that array than it is
to execute a fetch request with a predicate, which always round trips
to the store.
They key is "if you already have an array..." (Or a set.)
If you don't, then fetching a limited set with a predicate is
(usually) going to be considerably faster than fetching all objects,
and reducing the result after the fact with a predicate.
Consider what happens when you fetch all objects of a particular type.
Now consider what happens if you can give Core Data a predicate which
says "no, just these 3".
Jim
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden