NSURL Archives

How to list the contents of an NSURL

On the iOS simulator we have the luxury of peeking inside our virtual devices with the Finder. We can do this by heading over to the Finder, holding down Option and clicking Go. This will bring up the Library, in which you can navigate to Application Support / iPhone Simulator / 7.0 / Applications / […]

How to display a UIImage from an NSURL

If you’re displaying images from the main iOS bundle, things are fairly straightforward: self.imageView.image = [UIImage imageNamed:@”Amy.png”]; But if you have an NSURL to your image then it’s not as easy. It took me some digging to find out that you have to convert the URL into NSData first, and then display the data: NSData […]

How to copy a file from the Main Bundle into the Documents Directory in iOS

You can do this either by using paths or NSURLs. Apple recommends using NSURLs, so here’s how it works. In this example we’re copying a file called “Amy.png” which exists in the app’s main bundle. // file URL in our bundle NSURL *fileFromBundle = [[NSBundle mainBundle]URLForResource:@”Amy” withExtension:@”png”]; // Destination URL NSURL *destinationURL = [[self applicationDocumentsDirectory]URLByAppendingPathComponent:@”Amy.png”]; […]