• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using Keys to create Unique Attributes in CoreData?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Keys to create Unique Attributes in CoreData?


  • Subject: Re: Using Keys to create Unique Attributes in CoreData?
  • From: Charilaos Skiadas <email@hidden>
  • Date: Sat, 6 Aug 2005 19:11:45 -0500

On Aug 6, 2005, at 4:17 PM, Colin Cornaby wrote:

I know I'm using some terminology already in CoreData, but I think I'm using it for a different meaning, so I'll explain...

When I worked with Microsoft SQL/ASP all the way back in 2000, you could specify a key value in the schema for an entity. For example, I was coding a job database. A person could view jobs and send in their resumes. In the database, the job entity had it's job id set up as a key value (job id was an attribute of the job entity). That is, the database would only allow there to be one job entity with that job id. NSDictionary is something very similar in a way. All keys in an NSDictionary must be unique, if you try to add a object with a key value that already exists in the dictionary, the old one is overwritten.

Does CoreData have any way to do this? I have two values in an entity, and I want to make sure no other entity in the database has those two same values. I tried doing this progmatically with fetch requests and deleting manually but this was dog slow. I went from being able to handle around 800 entity adds in a second to about 800 in ten seconds. Is there a fast "good" way to do this, or even a built in way?

There's no built in way AFAIK, you'll have to come up with your own, but I would suggest cacheing the ids, possibly as keys in a dictionary, instead of trying to fetch them each time you want to see if you can add a new entity. I.e. keep a dictionary with keys all the ids, and maybe the corresponding objects as objects? This way, you are using the fact that dictionaries are already optimized to quickly find a key if it exists, or return nil if it doesn't.
---------------------------
Colin Cornaby - http://gomac.blogspot.com/
Carpe Stellarem - Lead Programmer, ProToys - http://carpestellarem.com
Macintosh Specialist - University of Portland - htttp://up.edu

Haris


_______________________________________________ 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
References: 
 >Using Keys to create Unique Attributes in CoreData? (From: Colin Cornaby <email@hidden>)

  • Prev by Date: Re: one additional piece of info about the pdfview problem
  • Next by Date: Re: Save authentication to keychain
  • Previous by thread: Using Keys to create Unique Attributes in CoreData?
  • Next by thread: Spell checking
  • Index(es):
    • Date
    • Thread