开发者

AssetsLibrary not producing failure when expected

开发者 https://www.devze.com 2023-03-31 08:52 出处:网络
I have this code: ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library assetForURL:albumCopy

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:

开发者_如何学PythonCould 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];
0

精彩评论

暂无评论...
验证码 换一张
取 消