CHECKING ASSET EXISTANCE OF ALAASSET IN IOS.

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
 473  View(s)
Ratings:
Rate this:

I have an array of urls that contains ALAsset urls. I want to check existance of any specific url.
I tried this code:

NSData *assets = [[NSData alloc] initWithContentsOfFile:@"asset-library://asset/asset.PNG?id=0X32031&ext=JPG"];

but the nsdata variable assets is always nil. So, how can I solve this problem?

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Checking asset existance of ALAasset in iOS.

    Here I am providing the code, which helps you to check existance of any specific url.
    this is the code:

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    [assetLibrary assetForURL:imageUrl resultBlock:^(ALAsset *asset){
     if(asset){
        NSLog(@"Image Exists");
        ALAssetRepresentation *assetRepresentation = [asset defaultRepresentation];
        UIImage *urlImage = [UIImage imageWithCGImage:[assetRepresentation fullResolutionImage]];
     } else {
        NSLog(@"Image Does't Exist");
     }
    } failureBlock:^(NSError *error) {
     NSLog(@"Failure");
    });

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!