• 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: adding something to a setter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adding something to a setter


  • Subject: Re: adding something to a setter
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 06 Oct 2011 19:12:02 -0700

On Oct 6, 2011, at 17:12 , Charles Srstka wrote:

> But isn't creating a whole abstract superclass for this a lot more of a hassle than just making a private property?

*Some* more. I'm not sure about a *lot* more.

> What would you get from that approach that you wouldn’t get from just having the getters and setters for a property “foo” call through to the synthesized accessors for a private property “privateFoo”?

Functionally, they're pretty similar, I guess -- one property uses another in both cases.

The only real experience I have with a dual-property approach is via Core Data (foo vs primitiveFoo -- imagine we're trying to put a 'setNeedsDisplay:' in a Core Data property override, so that we need to call through to primitiveFoo). It seems straightforward enough conceptually, but when you try to use it, things get hard.

Now if you find other functionality to add to the property, you have to ask yourself whether you're modifying the primitive property or the public property. Often, the answer is "Duh, I dunno." KVO can get tricky, because the notifications start to go round in circles or just break, and it's not clear how to fix the problem. You start having to guess how having two more or less identical properties interact with (say) undo. If you start subclassing, you again may have puzzling decisions about how and where to add overriding behavior.

I don't say it can't be done. I'm just saying when I've tried it for real I've found myself in a classic Houdini bind (that is, handcuffed, chained and locked in a steamer trunk at the bottom of a river) without actual Houdini skills to get me out.

But maybe that's just me.


_______________________________________________

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: 
 >adding something to a setter (From: Torsten Curdt <email@hidden>)
 >Re: adding something to a setter (From: Quincey Morris <email@hidden>)
 >Re: adding something to a setter (From: Torsten Curdt <email@hidden>)
 >Re: adding something to a setter (From: Quincey Morris <email@hidden>)
 >Re: adding something to a setter (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: adding something to a setter
  • Next by Date: -[NSURLCredentialStorage removeCredential:forProtectionSpace:] broken?
  • Previous by thread: Re: adding something to a setter
  • Next by thread: Re: adding something to a setter
  • Index(es):
    • Date
    • Thread