문제

I have this code:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library assetForURL:albumCopy
                 resultBlock:^(ALAsset *asset)  {
                     NSLog(@"success");
                     ...
}
            failureBlock:^(NSError *error) {
                    NSLog(@"fail");
                    ...
                }];
        [library autorelease];

The problem is that when I give it an image which doesn't exist, the NSLog comes up with:

Could not find photo 1000000141
success

If this won't show me when a photo doesn't exist, how can I find out?

도움이 되었습니까?

해결책

Solved it!

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library assetForURL:albumCopy
                 resultBlock:^(ALAsset *asset)  {
                     if (asset == nil) {
                         //Image not in photo library
                     }
                     else {
                     //Image in photo library
                     }
                 }
                failureBlock:^(NSError *error) {
                    //Error
                }];
        [library autorelease];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top