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

  • SEARCH
  • Home
  • 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 8996463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:45:29+00:00 2026-06-15T23:45:29+00:00

I am using this code to retrieve all images form my device but its

  • 0

I am using this code to retrieve all images form my device but its not returning an result

- (void)viewDidLoad
{
    [super viewDidLoad];
    void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
        if(result != NULL) {
            NSLog(@"See Asset: %@", result);
            [_assets addObject:result];
            // Here storing the asset's image URL's in NSMutable array urlStoreArr
            NSURL *url = [[result defaultRepresentation] url];
            [_urlStoreArr addObject:url];
        }
    };

    void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop)
    {
        if(group != nil)
        {
            [group enumerateAssetsUsingBlock:assetEnumerator];
        }
    };

    _urlStoreArr = [[NSMutableArray alloc] init];
    _assets = [[NSMutableArray alloc] init];
    _library = [[ALAssetsLibrary alloc] init];

    [_library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                           usingBlock:assetGroupEnumerator
                         failureBlock: ^(NSError *error) {
                             NSLog(@"Failure");
                         }];



    [self UploadImagesToServer];

}

-(void) UploadImagesToServer
{
    for (int i=0; i<[_urlStoreArr count]; i++)
    {
        // To get the each image URL here...

        NSString *str = [_urlStoreArr objectAtIndex:i];
        NSLog(@"str: %@",str);

        // Need to upload the images to my server..
    }
}
  • 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-15T23:45:30+00:00Added an answer on June 15, 2026 at 11:45 pm

    You are using the _urlStoreArr before it is initialized.

    When you are defining blocks, they take the current local value of variables that you use in the block.

    So, in the assetEnumerator block you are using _urlStoreArr but you aren’t initialising it until later in the code.

    I’m assuming that _urlStoreArr is an iVar, since it has a leading underscore. If you are using ARC, then the iVar is initialised to nil, so your assetEnumerator block is sending a message to nil. This is legal in Objective-C, but it just returns nil.

    You have two options to fix this.

    1. Move the declaration of _urlStoreArr = [[NSMutableArray alloc] init]; above the definition of the assetEnumerator block
    2. The preferred way – don’t use the iVar directly, use property syntax. i.e. rather than [_urlStoreArr addObject:url]; try [self.urlStoreArr addObject:url];. This works because when using property access, you aren’t using the current value of _urlStoreArr at the time of definition, you are using the value at the time the block runs, which is after the iVar has been initialised.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve all clientID from my MCC account. I'm using this code
I am using this code snippet to retrieve contact's email addressees but what I
Using this code, i am able to send a notification to my own device.
Right now I am using this code to retrieve the MAC Address of a
I'm using the following Code with the twitter4J library to retrieve all tweets of
Using this code to zip a folder and it works perfect on small files
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
Using This code: I am tring to fill the page with the data and
Im using this code: protected String getContactInfo() { Cursor cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, null,
When using this code: <script> $(document).ready(function () { $.getJSON(http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?, function(data) { if(data[0].text.length > 107)

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.