On Wed, 26 May 2010 03:08:31 +1000, Gideon King said: >I have found the problem. In awakeFromNib, I have several calls like this: > >[self addObserver:self forKeyPath:@"thingy" >options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew >context:NULL]; > >And in the dealloc method, I have: > >[self removeObserver:self forKeyPath:@"thingy"]; > >for all the same key paths. > >All looked normal enough. But in the init method of the class, I was >loading a nib that had my class as the file's owner, as well as being a >view controller for another view. Therefore, awakeFromNib was being >called twice, and although the dealloc was removing one set of >registrations, the other set was being left. In my core data classes, I >have all this wrapped in a boolean that avoids starting observing more >than once, but I wasn't doing that in this part of my code. > >I found the -observationInfo method useful in tracking this down - I >knew there must be some method like this, but had not found it before. > >Thanks for the suggestions etc.
Glad you've tracked it down. Just a comment though: my understanding is that calling removeObserver from dealloc is, in general, discouraged. See here for some reasoning: <http://www.karppinen.fi/analysistool/> -- ____________________________________________________________ Sean McBride, B. Eng s...@rogue-research.com Rogue Research www.rogue-research.com Mac Software Developer Montréal, Québec, Canada _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com