• 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: Custom Enable Binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Enable Binding


  • Subject: Re: Custom Enable Binding
  • From: Keary Suska <email@hidden>
  • Date: Tue, 13 Mar 2007 14:09:20 -0700
  • Thread-topic: Custom Enable Binding

on 3/13/07 10:12 AM, email@hidden purportedly said:

> I managed a hack to get it to work in the ArrayController, which is :
>
> -(void)awakeFromNib;
> {
>    //... other initialisation
>    [self addObserver:self forKeyPath:@"selectionIndexes"
> options:NSKeyValueObservingOptionNew context:NULL];
> }
>
> - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
> change:(NSDictionary *)change context:(void *)context;
> {
>    if ((self == object) && [keyPath isEqual:@"selectionIndexes"])
>    {
>        [self willChangeValueForKey:@"canMapSelectedElements"];
>        [self didChangeValueForKey:@"canMapSelectedElements"];
>    }
> }

This not really a hack, since it is essentially what the
+setKeys:triggerChangeNotificationsForDependentKey: does. You may want to
call [super observeValueForKeyPath: etc.], as the array controller might do
some of its own observing behind the scenes. Don't know if it matters, but
it's a habit I always do this when subclassing bindings-enabled objects. If
you don't get any other binding failings, it probably doesn't matter.

> But I thought the whole point of
> +setKeys:triggerChangeNotificationsForDependentKey: was to trigger the
> change notification for the dependent key so I don't have to do it
> explicitly! If I can't do it the way I originally tried, I'll just do
> the same thing in my custom view controller, rather than muddy the
> ArrayController subclass.

I don't recall the exact issues, but there are a lot of limitations with
dependent keys, especially multiple keys. I.e., if you call it twice for
different dependent keys, and the setKeys have a same key, one call seems to
be ignored. I ran into this issue recently, and had to home-grow my own
triggers. There was a brief discussion of some of these issues somewhere in
the archives.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

References: 
 >Re: Custom Enable Binding (From: Sanjay Samani <email@hidden>)

  • Prev by Date: Fwd: MEETING: Core Image Chicago CocoaHeads / CAWUG Tuesday 3/13 -
  • Next by Date: Re: Sharing a content view between two NSWindows
  • Previous by thread: Re: Custom Enable Binding
  • Next by thread: so many resource occupied by QCRenderer.
  • Index(es):
    • Date
    • Thread