• 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: Mike Abdullah <email@hidden>
  • Date: Thu, 06 Oct 2011 13:36:00 +0100

On 6 Oct 2011, at 13:09, Thomas Davie wrote:

> I don't know of any better way than simply writing the setters yourself.  One thing I'd love to see apple add to the language is allowing us to specify a code block to be included in setter and getting in the synthesize:
>
> @property (readwrite, retain, nonatomic) NSString *theValue;
>
> @synthesize (setCode={ [self setNeedsDisplay:YES]; }, getCode={ NSLog(@"It's being set"); });
>
> would be lovely if it desugared to this in the implementation:
>
> {
>    NSString *theValue;
> }
>
> - (NSString *)theValue
> {
>    { NSLog(@"It's being set"); }
>    return [[theValue retain] autorelease];
> }
>
> - (void)setTheValue:(NSString *)newTheValue
> {
>    if (theValue != newTheValue)
>    {
>        [theValue release];
>        theValue = [newTheValue retain];
>        { [self setNeedsDisplay:YES]; }
>    }
> }
>
> Does anyone have any comments on why that might not work, before I file a bug report to request it?

Well it would become rather unreadable for anything more than a single line of code._______________________________________________

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

  • Prev by Date: Re: adding something to a setter
  • Next by Date: Re: adding something to a setter
  • Previous by thread: Re: adding something to a setter
  • Next by thread: Re: adding something to a setter
  • Index(es):
    • Date
    • Thread