Binding problem : getter not called when property change
Binding problem : getter not called when property change
- Subject: Binding problem : getter not called when property change
- From: Eric Morand <email@hidden>
- Date: Mon, 02 Nov 2009 13:49:15 +0100
Hi guys,
I have a NSImageView instance that I want to display a default image
when the user delete its content - namely, I want it to display a
question mark instead of displaying an empty space.
The image view "Value" property is bound to the "icon" property of my
controller, which is of course an NSImage.
@interface MyController : Object {
NSImage * icon;
}
To achieve the desired behavior, I wrote the following getter and
setter :
#pragma mark GETTERS
- (NSImage *)icon {
if (nil != icon) {
return icon;
}
return [NSImage imageNamed:@"QuestionMark"];
}
#pragma mark -
#pragma mark SETTERS
- (void)setIcon:(NSImage *)newImage {
[self willChangeValueForKey:@"icon"];
[icon release];
icon = [newImage retain];
[self didChangeValueForKey:@"icon"];
}
The setIcon: method is successfully called when I delete the content
of the image view, sending nil as the newImage parameter. Great. But
the image view doesn't update its content. In other words, the icon
getter method is not called event though I added the willChange and
didChange calls.
Can anyone explain me what's wrong here ?
Thanks by advance,
Eric.
_______________________________________________
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