Fwd: Cocoa Custom NSCell Binding Issue
Fwd: Cocoa Custom NSCell Binding Issue
- Subject: Fwd: Cocoa Custom NSCell Binding Issue
- From: Sean Willson <email@hidden>
- Date: Fri, 13 Jan 2006 09:21:23 -0600
I just realized that when I replied to this that I did it to the person
directly and not the list. Sorry about that. Perhaps others can shine some
light on this problem.
If you're handling change notifications manually ("will" and "did"),
> your object must implement +automaticallyNotifiesObserversForKey:
> appropriately (see http://developer.apple.com/documentation/Cocoa/
> Conceptual/KeyValueObserving/Concepts/AutoVsManual.html). It may be
> easier just to write your setObjectValue: in such a way that it can
> be called in response to a user clicking in the custom NSCell.
>
> Hamish
>
I'm really not following you. I'm simply trying to get changes in a custom
NSCell to be fired to a bound model using bindings. Here is what I have in
my methods:
- (id)objectValue;
{
NSLog(@"objectValue");
return [NSNumber numberWithDouble:[self rating]];
}
- (void)setObjectValue:(NSObject *)object;
{
NSLog(@"setObjectValue");
// we understand how to convert from NSStrings and NSNumbers, anything
else is unexpected.
if (YES == [object isKindOfClass: [NSString class]]) {
[self setRating:[(NSString *)object doubleValue]];
}
else if (YES == [object isKindOfClass: [NSNumber class]]) {
[self setRating:[(NSNumber *)object doubleValue]];
}
else {
NSLog(@"%@ Invalid object %@, setting rating to 0",
NSStringFromSelector(_cmd), object);
[self setRating:0];
}
}
When the rating changes it calls setRating. I have tried calling the did and
will notifiers hoping that the NSArrayController is listening to it but
objectValue never gets called when it changes.
Has anyone written a custom NSCell and used bindings to bind it to an
underlying object? This seems like a really really simple problem.
Sean
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden