Re: Core Data validateForUpdate
Re: Core Data validateForUpdate
- Subject: Re: Core Data validateForUpdate
- From: "Sean McBride" <email@hidden>
- Date: Mon, 21 Dec 2009 16:50:59 -0500
- Organization: Rogue Research Inc.
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 email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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