• 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: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController


  • Subject: Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
  • From: Shaun Wexler <email@hidden>
  • Date: Thu, 7 Oct 2004 09:09:42 -0700

On Oct 7, 2004, at 8:57 AM, Gabriele de Simone wrote:

Esteemed members of the Cocoa Bindings cult,

It seems that if I add a new key to an NSArrayController and make "arrangedObjects" dependent on that key, the change notifications when the key is modified are never sent (or at least my views dependent on "arrangedObjects" don't get updated). Here's the scenario:

+ (void) initialize {
[self exposeBinding:@"myKey"];
[self setKeys:[NSArray arrayWithObjects:@"myKey", nil]
triggerChangeNotificationsForDependentKey:@"arrangedObjects"];
}

+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {

if ([key isEqualToString:@"myKey"]) {
return NO;
}

return [super automaticallyNotifiesObserversForKey:key];
}

- (void) setMyKey:(NSString*)myKey {

if (_myKey != myKey) {
[self willChangeValueForKey:@"myKey"];
_myKey = [myKey copy];
[self didChangeValueForKey:@"myKey"];
}
}

The obvious solution is to call [self rearrangeObjects] in the setter method, but I am more interested in knowing whether I have misunderstood/ignored some properties of NSControllers.

How are you going to automatically trigger a change notification for that key, if you disable automatic notification for the key?!! Use one or the other. It's okay to send your own -rearrangeObjects message in the setter if you prefer. Are you just trying to avoid rearranging unnecessarily, if the setter is called with the same key? BTW, it might be better to use isEqualToString: rather than compare pointers, since you're making a copy.
--
Shaun Wexler
MacFOH
http://www.macfoh.com

_______________________________________________
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
  • Follow-Ups:
    • Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
      • From: Gabriele de Simone <email@hidden>
References: 
 >triggerChangeNotificationsForDependentKey in subclass of NSArrayController (From: Gabriele de Simone <email@hidden>)

  • Prev by Date: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
  • Next by Date: nuking a controller (Java)
  • Previous by thread: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
  • Next by thread: Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
  • Index(es):
    • Date
    • Thread