Re: Cocoa Custom NSCell Binding Issue
Re: Cocoa Custom NSCell Binding Issue
- Subject: Re: Cocoa Custom NSCell Binding Issue
- From: Sean Willson <email@hidden>
- Date: Sat, 14 Jan 2006 15:21:12 -0600
i spent about 3 hours last night working on this and i can't reproduce this
behavior. here is what i have, perhaps someone can shine some light on my
ignorance:
// add the custom cell for setting the rating
WARatingIndicatorCell *cell = [[[WARatingIndicatorCell alloc] init]
autorelease];
[cell setMinValue:0.0];
[cell setMaxValue:5.0];
[cell setRating:0.0];
[cell setContinuous:NO];
[[coursesTable tableColumnWithIdentifier:@"Rating"] setDataCell:cell];
// setup the binding for the table column
[[coursesTable tableColumnWithIdentifier:@"Rating"] bind:@"value"
toObject:coursesController withKeyPath:@"arrangedObjects.rating"
options:nil];
that's how i'm setting my cell up. i've tried renaming the "value" to
"rating" as that is the name of the method on the cell but i get errors that
say the NSTableColumn isn't KV compiant for "rating". i have also tried
setting the binding on the cell itself, nada. here is what i have in the
cell:
- (void)bind:(NSString *)binding toObject:(id)observableObject
withKeyPath:(NSString *)keyPath options:(NSDictionary *)options;
{
if (YES == [binding isEqualToString:@"value"]) {
[observableObject addObserver:self forKeyPath:keyPath options:0
context:@"RatingValue"];
observedObjectForRating = [observableObject retain];
observedKeyPathForRating = [keyPath copy];
}
}
and finally, when i want to record a change i have this:
[observedObjectForRating setValue:[NSNumber numberWithDouble:newRating]
forKeyPath:observedKeyPathForRating];
so the behavior i get now is that the cell gets setup right at the start
with the initial values, i've always had that. BUT it never does anything
when i fire off the notifications to the controller of the change. i've
tried also changing the keypath to be selection.rating and other paths but i
get no where. this is exactly how the docs on this page:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html#//apple_ref/doc/uid/20002373-196748
suggest to do this so i followed it to the letter. i know that NSCell's
behave in terms of display a lot differently then a standalone element, i
found that out the hard way when i had to get drawing to work when resizing
the column. this is kinda crazy though.
any suggestions?
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