• 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
recursing bindings?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

recursing bindings?


  • Subject: recursing bindings?
  • From: Joshua Scott Emmons <email@hidden>
  • Date: Thu, 16 Jun 2005 15:59:31 -0400

Based on examples, I've written binding into a custom class of mine. This involves implementing bind... observeValueForKeyPath... and setValue... as follows:

-(void)bind:(NSString *)binding
   toObject:(id)observableObject
withKeyPath:(NSString *)keyPath
    options:(NSDictionary *)options{

observedObjectForIndex = [observableObject retain];
observedKeyPathForIndex = [keyPath copy];
[observableObject addObserver:self forKeyPath:keyPath options:nil context:(void *)@"thing"];
}



- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{

      id myValue = [object valueForKeyPath:keyPath];
      [self setValue:myValue];
   }
}


-(void)setValue:(NSString *)aValue{ [value release]; value = [aValue copy];

if(nil != observedObjectForIndex){
[observedObjectForIndex setValue:aValue forKeyPath:observedKeyPathForIndex];
}
}



The problem is, if I setValue..., this sends the value to the observable object. This, in turn, causes the observable object to message me with an observeValueForKeyPath... which causes me to setValue... which sets the observable object which causes it to message me with an obeserveValueForKeyPath... etc. etc.


How do I update the observable object I'm bound to without causing it to immediately send me an observeValueForKeyPath... with the value I just sent it?


Cheers, -Joshua Emmons _______________________________________________ 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: recursing bindings?
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: Wrong type of button in IB?
  • Next by Date: Binding Target of NSButtonCells inside of an NSTableView
  • Previous by thread: install app missing??
  • Next by thread: Re: recursing bindings?
  • Index(es):
    • Date
    • Thread