Re: AVAudioPlayer crash
Re: AVAudioPlayer crash
- Subject: Re: AVAudioPlayer crash
- From: Jens Alfke <email@hidden>
- Date: Thu, 19 Feb 2009 08:46:56 -0800
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 |
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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