Skip to content

Instantly share code, notes, and snippets.

@icomkid
Created June 2, 2011 07:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icomkid/1004042 to your computer and use it in GitHub Desktop.
Save icomkid/1004042 to your computer and use it in GitHub Desktop.
[iOS] Convert a bundle resource path to URL
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"intro" ofType:@"mov"];
NSURL *url = [NSURL fileURLWithPath:resourcePath];
@kristopherjohnson
Copy link

With iOS 4.0 and later, you do this:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"intro" withExtension:@"mov"];

@brunomunizaf
Copy link

I've been looking for this answer for 2 days. Thank you kristopherjohnson! the file's path wasn't working, all i needed was the url for resource. Most of the q&a's from stackoverflow were saying it was kinda confusing to get an url for an local image but... you've made it. Thank you again. :)

@MuneebSaeed4
Copy link

and where is tha file "@intro"??
I am trying to give path of an image selected from Photo Library (Simulator) and it is always nil
let URL = NSBundle.mainBundle().URLForResource("(localPath)", withExtension: "JPEG")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment