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?

Bob

if (*ra4 != 0xffc78948) { return false; }

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

> 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com
> 
> This email sent to tom.da...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to