• 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 12:33:37 -0700

On Oct 6, 2011, at 04:28 , Torsten Curdt wrote:

> Now you also want to setNeedsDisplay: when a new value is set. So one
> can override the setter.
>
> - (void)setValue:(NSString*)theValue
> {
>   ...
>   [self setNeedsDisplay:YES];
> }
>
> but - you would have to implement the setter yourself. No big deal -
> but... it sucks.

I think it really doesn't suck. You've just been lucky enough so far to be able to ride around on synthesized setters, so an override feels bad. Get over it already!

The only part of a setter override that perhaps hurts (other than having to type a few extra keystrokes) is that you lose access to the lightweight implementation of the "atomic" attribute. It's easy to obsess about that too, but the class of thread synchronization problems that atomicity actually solves, compared to the class of synchronization problems that need a higher-level strategy, is so small that it's not worth avoiding setters only for this reason.

By all means use self-observation if that solves your problem. There's absolutely nothing wrong with it, so any negative feelings you might have are just another perceptual problem. Note, however, that because the observer mechanism is so clunky, you're going to write *more* lines of code this way than in overriding the setter, yet all it buys you is the unwanted/unnecessary "atomic" implementation.

FWIW.


_______________________________________________

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: adding something to a setter
      • From: Torsten Curdt <email@hidden>
    • Re: adding something to a setter
      • From: Kyle Sluder <email@hidden>
References: 
 >adding something to a setter (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Why doesn't UIViewController retain its UISearchDisplayController
  • Next by Date: Re: Strange mystery with Core Animation
  • Previous by thread: Re: adding something to a setter
  • Next by thread: Re: adding something to a setter
  • Index(es):
    • Date
    • Thread