Home > DeveloperSection > Forums > Checking asset existance of ALAasset in iOS.
Jayden Bell
Jayden Bell

Total Post:110

Posted on    January-14-2016 4:53 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 455  View(s)
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?

Tarun Kumar

Total Post:214

Posted on    January-14-2016 11:04 PM

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){
    NSLog(@"Image Exists");
    ALAssetRepresentation *assetRepresentation = [asset defaultRepresentation];
    UIImage *urlImage = [UIImage imageWithCGImage:[assetRepresentation fullResolutionImage]];
 } else {
    NSLog(@"Image Does't Exist");
} failureBlock:^(NSError *error) {

Don't want to miss updates? Please click the below button!

Follow MindStick