Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:06:22+00:00 2026-06-14T03:06:22+00:00

I am using a UIImagePickerController to allow users to select an image from the

  • 0

I am using a UIImagePickerController to allow users to select an image from the image library. I then want to start the location of that file in a sqlite database so I can refer to it later.

I’ve been doing some googling about how to do this and I’m coming up rather short. I know I can get the ReferenceURL of the item by calling inside the delegate method:

    NSURL *picURL = [info objectForKey:@"UIImagePickerControllerReferenceURL"]

This does give me a valid NSURL object and if I output picURL.absoluteString I can what appears to be a valid url to the assets-library location of the file. However, if I try to create an NSData object with this url so I can in turn create a UIImage, the code fails because NSData returns nil. For example:

    NSURL *picURL = [info objectForKey:@"UIImagePickerControllerReferenceURL"]
    NSString *stringUrl = picURL.absoluteString;
    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:stringUrl]];
    imgMain.image = [UIImage imageWithData:data]

I realize I’m being somewhat repetitive here but the point is to grab a string representation of the URL that I can store in sqlite and then use said string later to create an image (so the above code represents that train of thought).

I found some information floating around about using ALAssetsLibrary but that gave me all kinds of fits as it doesn’t appear to play nice with iOS 5 and ARC. I keep getting error messages ‘Receiver type ALAsset for instance message is a forward declaration. I can set properties on the file that references ALAsset / ALAssetsLibrary to ignore ARC which stops the build error but then as soon as I leave the code block the data goes away. See below:

    NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    __block UIImage *returnValue = nil;
    [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
        returnValue = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
    } failureBlock:^(NSError *error) {
       // error handling
    }];
    [library release];

returnValue does return a valid image but as soon as the code exits the resultBlock the contents of the data are gone (i.e. returnValue becomes null again).

So my question is: how do I use the UIImagePickerControllerReferenceURL and convert it to a string I can store in sqlite and then use said string to create a valid UIImage object at a later time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:06:23+00:00Added an answer on June 14, 2026 at 3:06 am

    Looks like you’re on the right track, for saving the asset url.

    Save
    NSURL *picURL = [info objectForKey:@"UIImagePickerControllerReferenceURL"]
    NSString *stringUrl = picURL.absoluteString;
    
    
    Reload AssetURL
    NSURL asssetURL = [NSURL URLWithString:stringUrl]
    

    As for loading the asset later on, i’m going to base on the assumption you’re not using arc. Which would explain why you’re returnValue is nil.

    Have you tried adding a retain to the result? for example:

        NSURL *referenceURL = [NSURL URLWithString:savedAssetURLString]
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        __block UIImage *returnValue = nil;
        [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
            returnValue = [[UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]] retain]; //Retain Added
        } failureBlock:^(NSError *error) {
           // error handling
        }];
        [library release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i want to select the video from library by using UIImagePickerController.
I am using UIImagePickerController to select the image from the PhotoLibrary in my application.
I'm using UIImagePickerController to allow my user to select a video from the asset
In my project I am using the UIIamgepickercontroller to select an image from the
I am using following code to choose image from camera role picker= [[UIImagePickerController alloc]
I am using the UIImagePickerController in order to let the user select an image
I am taking pictures from the iPhone camera using the UIImagePickerController Class. I am
I'm trying to present a UIImagePickerController from a UITableViewController subclass using the following code:
Is that possible to present a UIImagePickerController inside a view, instead of using it
I am having problems using choosing an image from my camera roll and assigning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.