evan.stoddard
evan.stoddard

Reputation: 698

NSURL from NSBundle path returns nil

So I'm trying to use a video as a background and I have a .mov file in my app and when I run this code:

NSBundle * bundle = [NSBundle mainBundle];

NSString * urlString = [bundle pathForResource:@"movie" ofType:@"mov"];
NSURL * movieURL = [NSURL URLWithString:urlString];

if (!movieURL) {

    NSLog(@"Not valid");

}

I get Not valid in the console. I checked urlString and it is giving me a url and I'm positive that the file is named correctly and is not in a directory.

So its here...

So the file is there and is copied into the source. Not sure why this is doing this.

Upvotes: 2

Views: 1114

Answers (1)

rmaddy
rmaddy

Reputation: 318944

You want to use:

NSURL *moveiURL = [NSURL fileURLWithPath:urlString];

Better yet, use:

NSURL *moveURL = [bundle URLForResource:@"movie" withExtension:@"mov"];

Upvotes: 4

Related Questions