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 8067683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:24:15+00:00 2026-06-05T12:24:15+00:00

i am using asset library for getting image from url , my code is

  • 0

i am using asset library for getting image from url , my code is

ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){     
    ALAssetRepresentation *rep = [myasset defaultRepresentation];
    CGImageRef iref = [rep fullResolutionImage];
    UIImage *largeimage;

    if (iref) {
        largeimage = [UIImage imageWithCGImage:iref];
    }

    [self customeButtonCreated:self];

    NSData* thumbImageData = [[NSData alloc] initWithContentsOfFile:imagePath];
    btn1.frame = CGRectMake(x, y, WIDTH, HEIGHT);
    [btn1 setTag:tag];

    //[media_id addObject:[allKey objectAtIndex:0]];     
    [btnURl addObject:imagePath];

    UIImage *tempImage = [[UIImage alloc]initWithData:thumbImageData];
    [btn1 setImage:largeimage forState:UIControlStateNormal];
    btn1.imageView.contentMode = UIViewContentModeScaleAspectFit;           
    [tempImage release];

    [newView addSubview:btn1];
    [btn1 addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [thumbImageData release];

    imgcount++;

    NSLog(@"Iamge count ---%d",imgcount);
    tag++;
};

ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror){
    NSLog(@"Cannot get image - %@",[myerror localizedDescription]);
};


if ([seprateArr count] == 2) {
    NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"assets-library://asset/asset.JPG?id=%@&ext=%@",[seprateArr objectAtIndex:0],[seprateArr objectAtIndex:1]]];
    ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
    [assetslibrary assetForURL:url resultBlock:resultblock failureBlock:failureblock];
}

it is working fine in ios – 4 or below but in ios – 5 it is not entering in block and showing errir

Cannot get image – Global denied access

any solution for this ?

  • 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-05T12:24:17+00:00Added an answer on June 5, 2026 at 12:24 pm

    This works for me in ios 4.0 as well as ios 5.

    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    NSString *photoName;
    NSString *photoUrl;
    
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
        void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) 
        {
            if(result != NULL) 
            {
                NSArray *arrKeys = [[result valueForProperty:ALAssetPropertyURLs]allKeys];             
                if([[result valueForProperty:ALAssetPropertyType]isEqualToString:ALAssetTypePhoto])
                {
                    if([[UIDevice currentDevice] systemVersion]>=5.0))
                    {
                        photoName = [[result defaultRepresentation]UTI];
    
                    }
                    else
                    {
                        photoName = [[result defaultRepresentation]filename];
    
                    }
                    //Your code here
                    photoUrl = [[result valueForProperty:ALAssetPropertyURLs]objectForKey:[arrKeys objectAtIndex:0]];
    
                }
            }
        };
    
        void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop) 
        {
            if(group != nil) 
            {
                [group enumerateAssetsUsingBlock:assetEnumerator];
            }
        };
        [library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:assetGroupEnumerator failureBlock:^(NSError *error){
            NSLog(@"%@",error);
        }];
    
        [pool release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm storing the file location in the asset library of photos taken using the
I've got a many to many relationship from Project to Asset using ProjectAsset class
I am getting the following result from converting xml to JSON, using more than
I am recording a video from the iPhone camera by using the AVCam code
How to play the video file from assets library? I have the URL of
I need to get the meta data of the image from the library. I
I am using Underscore library and using its template feature. But i am getting
I'm using UIImagePickerController to allow my user to select a video from the asset
I wish to extract the image using ALAssetsLibrary and ALAsset directly in the form
I'm using jQuery Lightbox in my Rails 3.1 app. I'm using the asset pipeline,

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.