Re: Multiple Observations
Re: Multiple Observations
- Subject: Re: Multiple Observations
- From: Lee Ann Rucker <email@hidden>
- Date: Fri, 14 Jun 2013 14:30:09 -0700
On Jun 14, 2013, at 1:06 PM, Gordon Apple wrote:
> - (void)awakeFromNib {
> [self.doc addObserver:self
> forKeyPath:@"currentPath"
> options:NSKeyValueObservingOptionNew |
> NSKeyValueObservingOptionOld
> context:nil];
> }
>
> - (void)observeValueForKeyPath:(NSString *)keyPath
> ofObject:(id)object
> change:(NSDictionary *)change
> context:(void *)context {
>
> if (object == self.doc && [keyPath isEqualToString:@"currentPath"] &&
> self.outlineView != nil) {
> [self.outlineView reloadData];
>
> // Debugging
> static NSUInteger dingCount = 0;
> dingCount++;
> NSLog(@"dingCount = %lu", dingCount);
> }
> }
>
> ³currentPath² property in doc gets set once. Observation gets dinged about
> 200 times. Removing the ³reloadData² didn¹t affect this. Same observer in
> another file gets dinged once, like it should. Stack trace always leads
> back to where "currentPath" is set in doc. Any theories on what could cause
> this observer to have diarrhea?
If it's not multiple calls to the setter, could it be multiple calls to awakeFromNib? What does the observationInfo on self.doc look like?
_______________________________________________
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