• 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
unique properties using Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unique properties using Core Data


  • Subject: unique properties using Core Data
  • From: C Thomas <email@hidden>
  • Date: Wed, 13 Jul 2005 11:29:42 -0500


Core Data uses so much of the database paradigm that I expected to see an option to choose to make a property unique... but failing that, I am trying to implement uniquing myself...


My entity's name property needs to be unique within the managed object context. So, I'd like to validate it before I insert it, and 'validateForInsert' seems like the logical way to do that.

My problem is that I can't even set the property until I've already inserted the NSManagedObject into the context using (id) initWithEntity:(NSEntityDescription*)entity insertIntoManagedObjectContext:(NSManagedObjectContext*)context. By then, it's too late - I've already inserted it.

Can somebody explain how to use validateForInsert?

In case i'm about to be advised to use validateValueForKey instead, I can't do that since core data seems to call that method for each object upon exit - to make sure that all of the objects are in a valid state, I suppose.

Is there some sort of context-dependant method like validateValueForInsert or something like that? For a property that must be unique, the property can be valid for insert, but once it's inserted it's no longer a valid property to insert.




_______________________________________________ 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
  • Follow-Ups:
    • Re: unique properties using Core Data
      • From: Charilaos Skiadas <email@hidden>
  • Prev by Date: Host name of remote volume
  • Next by Date: Re: Host name of remote volume
  • Previous by thread: Re: How to get container when overriding NSCreateCommand
  • Next by thread: Re: unique properties using Core Data
  • Index(es):
    • Date
    • Thread