• 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
Re: Cocoa Custom NSCell Binding Issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Cocoa Custom NSCell Binding Issue (From: Hamish Allan <email@hidden>)

  • Prev by Date: Hex Editor
  • Next by Date: Re: Notifications when iPods are mounted...
  • Previous by thread: Re: Cocoa Custom NSCell Binding Issue
  • Next by thread: Re: Cocoa Custom NSCell Binding Issue
  • Index(es):
    • Date
    • Thread