• 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: How does bind:toObject:withKeyPath:options: work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does bind:toObject:withKeyPath:options: work?


  • Subject: Re: How does bind:toObject:withKeyPath:options: work?
  • From: Pierre Molinaro <email@hidden>
  • Date: Thu, 17 Apr 2008 12:17:11 +0200

Hi,

It seems that -willChangeValueForKey and -didChangeValueForKey of NSArrayController are called on arrangedObjects change.

I think you can use of a class that inherits from NSArrayController where theses methods are redefined to send manually change notifications:


- (void) willChangeValueForKey: (NSString *) inKey { if ([inKey isEqualToString:@"arrangedObjects"]) { [self noteOldValueOfArrangedObjects] ; } [super willChangeValueForKey:inKey] ; }

- (void) didChangeValueForKey: (NSString *) inKey {
  [super didChangeValueForKey:inKey] ;
  if ([inKey isEqualToString:@"arrangedObjects"]) {
    [self sendChangeNotifications] ;
  }
}


Pierre

Le 17 avr. 08 à 11:54, Hamish Allan a écrit :

Hi,

I am attempting to work around a bug in NSArrayController by trying to
propagate change notifications for arrangedObjects manually, as if I
had bound the key path of another object to it (see
http://www.cocoabuilder.com/archive/message/cocoa/2008/4/17/204421 for
why that doesn't work).

However, by the time I receive the change notification for
arrangedObject, its value has already been updated, so it is too late
for me or any other part of the bindings system to send
willChangeValueForKey:. Therefore any observer of the downstream value
will also be told the same values for NSKeyValueObservingOptionOld and
NSKeyValueObservingOptionNew.

Is there any reason why the design of bindings requires, but does not
provide, notification that a value will change?

How does the default implementation of
bind:toObject:withKeyPath:options: work in the face of this?

Thanks,
Hamish
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: How does bind:toObject:withKeyPath:options: work?
      • From: "Hamish Allan" <email@hidden>
References: 
 >How does bind:toObject:withKeyPath:options: work? (From: "Hamish Allan" <email@hidden>)

  • Prev by Date: Re: Implicit animation duration
  • Next by Date: Re: 1-bit NSBitmapImageRep?
  • Previous by thread: How does bind:toObject:withKeyPath:options: work?
  • Next by thread: Re: How does bind:toObject:withKeyPath:options: work?
  • Index(es):
    • Date
    • Thread