On 12/20/09 3:19 PM, Gerriet M. Denkmann said: >What I try to accomplish: >SomeEntity has a property called "uniqueKey" and this is (no big >surprise) meant to be unique. > >When the "UniqueKey" column in my table view gets edited, >validateUniqueKey:error: gets called, I check the new value for >uniqueness and all is fine. > >But hitting the "+" button several times inserts several objects with >the same key (Default Value).
As others have said, you probably want awakeFromInsert. Depending what kind of 'unique' value you want, you could create a unique string like this: CFUUIDRef uuid = CFUUIDCreate (kCFAllocatorDefault); if (uuid) { uuidStr = NSMakeCollectable (CFUUIDCreateString (kCFAllocatorDefault, uuid)); CFRelease (uuid); } If you want/need to compare to other objects of the same entity type, then be warned that performing a fetch within awakeFromInsert is probably not a good idea. NSArrayController doesn't like it when you do that. -- ____________________________________________________________ Sean McBride, B. Eng s...@rogue-research.com Rogue Research www.rogue-research.com Mac Software Developer Montréal, Québec, Canada _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com