• 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: Core Data validateForUpdate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Core Data validateForUpdate
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >Core Data validateForUpdate (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Version number objects
  • Next by Date: Re: tracking EXC_BAD_ACCESS error in applescript command
  • Previous by thread: Re: Core Data validateForUpdate
  • Next by thread: Re: Core Data validateForUpdate
  • Index(es):
    • Date
    • Thread