• 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: AVAudioPlayer crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AVAudioPlayer crash


  • Subject: Re: AVAudioPlayer crash
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 19 Feb 2009 08:46:56 -0800


email@hidden wrote:

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

References: 
 >Re: AVAudioPlayer crash (From: email@hidden)

  • Prev by Date: Re: AVAudioPlayer crash
  • Next by Date: Re: AVAudioPlayer crash
  • Previous by thread: Re: AVAudioPlayer crash
  • Next by thread: Re: AVAudioPlayer crash
  • Index(es):
    • Date
    • Thread