Re: Unique items in Core Data models
Re: Unique items in Core Data models
- Subject: Re: Unique items in Core Data models
- From: mmalc crawford <email@hidden>
- Date: Tue, 15 May 2007 14:59:11 -0700
On May 15, 2007, at 2:52 PM, mmalc crawford wrote:
But that still leaves the issue of determining uniqueness of a
Title :-)
Sorry, I pressed Deliver by accident...
As noted in a previous post, the naive technique for determining the
uniqueness of a given attribute (for example, a Title's title) is to
simply execute a fetch with a predicate for <uniquedAttributeName> =
<value> and check that the returned array has a count of 0. This is,
however, potentially very expensive.
If you're creating several unique values at the same time, the first
thing to do would be to combine all the values into a single fetch.
Better still, though, maintain an application-global dictionary of
existing unique values. The key can be the uniqued value, the
corresponding value in the dictionary is the objectID of the
corresponding managed object (you can use the objectID in any managed
object context...). Thus rather than executing a fetch, you check the
local cache.
Chris may have more to say about this pattern...
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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