1

I am trying to retrieve an image from the ALAssets library using a URL, calling assetforURL, but neither the result nor completion blocks are ever called. Something like this:

[library assetForURL:assetURL
    resultBlock:^(ALAsset *myasset){
        NSLog(@"asset found");
    }
    failureBlock:^(NSError *error){
        NSLog(@"error");
    }];

I know that assetforURL is asynchronous and that the blocks will be called sometime later. But they seem to be never called. I never see the output from the NSLog, and if I put in breakpoints, they are never reached.

What I'm really trying to do is associate images with items in a database. I store the asset URLs in the database, and then use the code above to retrieve them. Is there a different way of doing this? I havn't been able to find any examples of anything like this.

Thanks!

  • Please look this this link. click [a link](http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone) – Mahesh Aswathanarayana Oct 01 '13 at 02:14
  • Thanks - this link is useful, but doesn't help explain why the blocks are never called. – dpgroteapps Oct 14 '13 at 21:07
  • This was eventually solved - the library was not being properly initialized. I was surprised when I noticed that calling assetForURL when library was null didn't cause a crash. – dpgroteapps Nov 03 '13 at 18:49
  • Also, I ended up changing how I handle images. Now, I put a tag in the image metadata and save the tag in the database. This seemed more robust than dealing with asset URLs - the URLs are not well documented as to exactly what they are and how persistent they are. – dpgroteapps Nov 03 '13 at 18:52

0 Answers0