• 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
Binding problem : getter not called when property change
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Binding problem : getter not called when property change
      • From: Uli Kusterer <email@hidden>
  • Prev by Date: Re: Editing in a tableview without selecting
  • Next by Date: Re: Binding problem : getter not called when property change
  • Previous by thread: Re: Handling projects with several XIBs
  • Next by thread: Re: Binding problem : getter not called when property change
  • Index(es):
    • Date
    • Thread