Re: simple(?) NSSound selector not recognized error
Re: simple(?) NSSound selector not recognized error
- Subject: Re: simple(?) NSSound selector not recognized error
- From: "Shawn Erickson" <email@hidden>
- Date: Thu, 16 Aug 2007 11:55:53 -0700
On 8/16/07, Russ McBride <email@hidden> wrote:
>
>
> Thanks for the reply Shawn. This seems like it should be really simple, but
> I still can't seem to figure out why I'm getting a "selector not recognized"
> error when I try to pause a playing sound. When I pause a playing built-in
> system sound everything works find. But I get the error when I try to pause
> a playing sound for a local file.
>
> I'll provide a bit more code:
(on a side note your questions aren't related to Core Audio and likely
should be directed to the Cocoa-Dev list)
You are getting bitten by a basic memory management issue. Read at
least the following to save yourself pain / time in the future...
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html>
> - (void)setTheSound:(NSSound *)newSound
> {
> theSound = newSound;
> [theSound setDelegate:self];
> }
The above code is the problem since it doesn't make any attempts to
ensure the object set stays around. If was implemented as follows your
issue should go away...
- (void)setTheSound:(NSSound *)newSound
{
if (newSound != theSound) {
[theSound release];
theSound = [newSound retain];
[theSound setDelegate:self];
}
}
...because your setTheSound method isn't currently doing something
like the above the following lines are the source of your problem...
selectedSound = [NSSound soundNamed:selectedSoundAsString];
[self setTheSound:selectedSound];
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden