Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Working with Images > Recipe: Retrieving Images from Asset URLs

Recipe: Retrieving Images from Asset URLs

When image picker controllers retrieve images, they offer URLs that point to the selected image. A typical URL looks something like this:

assets-library://asset/asset.JPG?id=553F6592-43C9-45A0-B851-28A726727436&ext=JPG

You retrieve it from the picker’s info dictionary:

NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];

This URL offers continued direct access to the asset in question even though your application normally is not given permission to access the system’s onboard DCIM folder. You can use this URL to load images at any time, even after the image picker is no longer in use.

Recipe 7-2 demonstrates how to use the Assets Library to pull out an image via its URL. To compile this application, you must add the AssetsLibrary framework to your build phases. This recipe is device-only. It will compile but crash at runtime on the iOS simulator when you ask the retrieved asset representation for its data.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint