NSURL from NSBundle path returns nil

evan.stoddard

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.

rmaddy

You want to use:

NSURL *moveiURL = [NSURL fileURLWithPath:urlString];

Better yet, use:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related