• 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: Mark Townsend <email@hidden>
  • Date: Sun, 20 Dec 2009 08:26:29 -0800

I think that you want to implement the awakeFrom* methods on NSManagedObject
rather than the validate* methods for your purposes.

But as for them never getting called, make sure that your NSArrayController
bindings are correct.  Specifically that it's mapped to your NSManagedObject
subclass.  Also, check the method signature on your validate* methods.  Do
they return a BOOL and pass in a NSError ** for a parameter?

Cheers,
Mark

---
Mark Townsend
http://www.markltownsend.com


On Sun, Dec 20, 2009 at 4:00 AM, Mike Abdullah <email@hidden>wrote:

> I think you misunderstand what -validateForInsert: and friends are for.
> They use "insert" here in the sense of inserting into the persistent store.
>
> So -validateForInsert: is called the first time the object is added to the
> store (calling -[NSManagedObjectContext save:] ). From then on,
> -validateForUpdate: will be called at each save that will modify the object.
> And finally, -validateForDelete: if removing from the store.
>
> On 20 Dec 2009, at 08:19, Gerriet M. Denkmann wrote:
>
> > I have a document based Core Data app.
> >
> > MyDocument.nib contains an NSTableView bound to an NSArrayController.
> > There also are "+" and "-" buttons, which send "add:" resp. "remove:" to
> the array controller.
> >
> > SomeEntity.m (subclass of NSManagedObject) implements validateForInsert:,
> validateForUpdate: and validateForDelete: - none of which are ever called.
> Why?
> >
> > 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).
> >
> > What should I do? How to make validateForInsert: get called? 10.6.2.
> >
> >
> > Kind regards,
> >
> > Gerriet.
> >
> > _______________________________________________
> >
> > 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
>
> _______________________________________________
>
> 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
>
_______________________________________________

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

References: 
 >Core Data validateForUpdate (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Core Data validateForUpdate (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: iPhone Simulator auto-rotation touches detection bug?
  • Next by Date: Customizing NSTableViewHeader
  • Previous by thread: Re: Core Data validateForUpdate
  • Next by thread: Re: Core Data validateForUpdate
  • Index(es):
    • Date
    • Thread