• 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: Detecting Managed Object Property Change From Undo Redo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting Managed Object Property Change From Undo Redo


  • Subject: Re: Detecting Managed Object Property Change From Undo Redo
  • From: Keary Suska <email@hidden>
  • Date: Tue, 27 Jan 2015 07:46:04 -0700

> What in the world is that nonCompliantKVCivar?  I tried it in my project, on the ‘rating’ property as in my YouTube video.
>
> - (void)setPrimitiveRating:(NSNumber*)newRating {
>    rating = newRating ;
> }
>
> Does not compile.  The compiler never heard of ‘rating’.  Same result if I change it to _rating, m_rating or nonCompliantKVCrating.  OK, so then I added an ivar: _rating, and now of course
>   _rating = newRating ;
> compiles.

Remember that the compiler can't know anything about your model as all of that is specified at runtime. I wouldn't have expected CD to be smart enough to match up to a simply ivar declaration but it makes sense. Better, however, to have a property declaration, which would also synthesize an ivar in modern LLVMs (as of Xcode 5?).

> It still persists!

It will if you modeled it, which I didn't notice, but must be the case. It won't if you simply define an ivar or a property on your class and implement the relevant methods, however accurately.

> - (void)setPrimitiveRating:(NSNumber*)newRating {
>    rating = newRating ;
>    [super setPrimitiveRating:newRating] ;
> }
>
> Result: Compiler warning that my superclass (eventually, NSManagedObject) did not implement this method, a crash at runtime confirming that.

If we stop and think a moment, why would calling super ever work? This is still Objective-C, and calling super is only valid when the class' superclass implements the method. And I bet NSManagedObject doesn't...

> Conclusion: Primitive accessors are potentially useful but more study is needed to understand how they work, and in particular how to override them without breaking stuff.

Primitive methods are simply the methods for setting an objects values without being noticed--i.e. w/o causing KVO or changes notifications to be sent. I am sure you understand why. There is absolutely nothing magical about them, because they need to be entirely un-magical to escape CD's notice. Therefore it is really hard to break anything unless you deliberately do so (or deliberately ignore compiler warnings).

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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: Detecting Managed Object Property Change From Undo Redo
      • From: Jerry Krinock <email@hidden>
References: 
 >Detecting Managed Object Property Change From Undo Redo (From: Richard Charles <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Mike Abdullah <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Jerry Krinock <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Richard Charles <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Jerry Krinock <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Richard Charles <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Jerry Krinock <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Jerry Krinock <email@hidden>)
 >Re: Detecting Managed Object Property Change From Undo Redo (From: Quincey Morris <email@hidden>)

  • Prev by Date: NSTableCellView Constraints?
  • Next by Date: Re: Detecting Managed Object Property Change From Undo Redo
  • Previous by thread: Re: Detecting Managed Object Property Change From Undo Redo
  • Next by thread: Re: Detecting Managed Object Property Change From Undo Redo
  • Index(es):
    • Date
    • Thread