Re: AVAudioPlayer crash
Re: AVAudioPlayer crash
- Subject: Re: AVAudioPlayer crash
- From: email@hidden
- Date: Thu, 19 Feb 2009 11:51:45 -0500 (EST)
Yeah, that was it. Figured I'd get a compiler error, but I understand why I didn't now.
Thanks for y'alls help.
->Ken
-----Original Message----- From: Jens Alfke Sent: Feb 19, 2009 11:46 AM To: email@hidden Cc: Hamish Allan , email@hidden Subject: Re: AVAudioPlayer crash
The following code sequence crashes with a "[NSObject doesNotRecognizeSelector]" message.
NSString *path = [[NSBundle mainBundle] pathForResource:@"chainsa" ofType:@"caf"];
NSURL *chainSawURL = [NSURL fileURLWithPath:path];
_avChainSawSound = [[AVAudioPlayer alloc] initWithContentsOfURL:chainSawURL];
Any clues why? Or is AVAudioPlayer not the proper way to do this?
As Hamish said, you're calling a method the class doesn't implement — extra parameters are not optional in Obj-C.
In most cases the compiler would give you a warning when calling an unrecognized method. Unfortunately, -init methods are an exception, because the +alloc method's return type is 'id', which is untyped (it's the Obj-C equivalent of void* for objects.) Obj-C is kind of halfway between the strict type-checking of C++/Java, and the dynamic typing of Ruby/Python/PHP/etc. Usually I find this a nice place to be, but sometimes it's a pain.
In any case, if you get the -doesNotRecognizeSelector: exception, that is a nearly sure-fire indication that you've messed up your types. Look at the most recent stack frame that's in your code, and that's probably where the problem is.
—Jens
|
_______________________________________________
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