• 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: another n00b question -- addObserver weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: another n00b question -- addObserver weirdness


  • Subject: Re: another n00b question -- addObserver weirdness
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 11 Nov 2008 11:48:28 -0800

On Nov 11, 2008, at 10:35, John Zorko wrote:

2008-11-11 10:05:51.538 Magnatune[1382:20b] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <MagnatuneAppDelegate 0x11d3b0> for the key path "buffersEmpty" from <AudioStreamer 0x90fe00> because it is not registered as an observer.'

The MagnatuneAppDelegate address (11d3b0) is the same, so i'm adding observers to / removing observers from the same (and only) instance. Why does Cocoa then think that I didn't add the "buffersEmpty" observer when I clearly did?

The crash happens here, in the MagnatuneAppDelegate -stopStream method:

- (void)stopStream
{
	if (streamer)
	{
		[streamer removeObserver:self forKeyPath:@"buffersEmpty"];
		[streamer stop];
	}
}

With the code you've shown, it appears you'd crash exactly like that if 'stopSteam' was called twice. If that's a possibility, you'd want something like:


- (void)stopStream
{
	if (streamer)
	{
		[streamer removeObserver:self forKeyPath:@"buffersEmpty"];
		[streamer stop];
		streamer = nil; // add appropriate memory management here, of course

	}
}

_______________________________________________

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


References: 
 >another n00b question -- addObserver weirdness (From: John Zorko <email@hidden>)

  • Prev by Date: Re: How are we supposed to retrieve the generic bundle icon?
  • Next by Date: Re: REĀ : How are we supposed to retrieve the generic bundle icon?
  • Previous by thread: another n00b question -- addObserver weirdness
  • Next by thread: Search field menu resets
  • Index(es):
    • Date
    • Thread