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 (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