Finspoo Lee
Finspoo Lee

Reputation: 1

URLForResource:withExtension: method always returns nil

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

Upvotes: 0

Views: 2699

Answers (1)

Anomie
Anomie

Reputation: 94794

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.

Upvotes: 5

Related Questions