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

adding something to a setter


  • Subject: adding something to a setter
  • From: Torsten Curdt <email@hidden>
  • Date: Thu, 06 Oct 2011 13:28:43 +0200

The property syntax is great until you need one more thing.

Think of a NSView and that view displays a value.

 @synthesize value;

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.
Is there a way to forward the setting to the originally synthesized
setter? Super cannot be it.

Of course one could add another selector that to the interface

  - (void) setValueAndUpdateDisplay:(NSString*)theValue
  {
    self.value = theValue;
   [self setNeedsDisplay:YES];
  }

...but that sucks, too.

There gotta be a better way!
How do you deal with this?

cheers,
Torsten
_______________________________________________

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: Yi Lin <email@hidden>
    • Re: adding something to a setter
      • From: Quincey Morris <email@hidden>
    • Re: adding something to a setter
      • From: glenn andreas <email@hidden>
    • Re: adding something to a setter
      • From: Stephan Michels <email@hidden>
    • Re: adding something to a setter
      • From: Thomas Davie <email@hidden>
  • Prev by Date: Re: Writing a simple vector graphics editor - how to implement?
  • Next by Date: Re: Windows _findfirst , _findnext (koko)
  • Previous by thread: Re: NSArrayController Selection and Managed Object Context Undo
  • Next by thread: Re: adding something to a setter
  • Index(es):
    • Date
    • Thread