0

I am testing the MixerHost sample code. However the following code: NSURL *beatsLoop = [[NSBundle mainBundle] URLForResource: @"beatsMono" withExtension: @"caf"]; the beatsLoop is nil.

What's the reason for that? Should I first create the beatsMono.caf file and then put into some specific path?

Any comments and solutions will be highly appreciated.

Thanks, finspoo

Finspoo Lee
  • 1
  • 1
  • 1

1 Answers1

5

Should I first create the beatsMono.caf file and then put into some specific path?

Yes. The file beatsMono.caf (case sensitive!) must exist in your application bundle for that method to succeed. This is done by adding the file to the target as a resource in XCode, you cannot do it at runtime.

Anomie
  • 92,546
  • 13
  • 126
  • 145
  • Thank you Anomie for your quick answer. – Finspoo Lee Mar 20 '11 at 01:00
  • Thank you Anomie for your quick answer. As I am new to iOS development, How can I add that file to the target? (right click on Target -> Add -> what else?) Or can I try it by another file such as test.txt? – Finspoo Lee Mar 20 '11 at 01:06
  • 2
    @FinspooLee: In XCode 3, I would normally right-click on the Resources group and choose Add → Existing Files...; when it asks, choose to "Copy items into destination group's folder (if needed)". I don't know whether the same works in XCode 4, or if they changed that like they changed so much else. – Anomie Mar 20 '11 at 01:19
  • Hi Anomie, it works. Thank you again. Your answer save me lots of time and troubles. -finspoo – Finspoo Lee Mar 20 '11 at 01:41
  • @FinspooLee: You're welcome, and congratulations on your first question here. Don't forget to accept the best answer to each of your questions by clicking the check box outline to the left of the answer. – Anomie Mar 20 '11 at 01:49