0

我有这个代码:

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

问题是,当我给它一个不存在的图像时,NSLog 会出现:

找不到照片 1000000141
成功

如果当照片不存在时这不会显示我,我该如何找到?

4

1 回答 1

2

解决了!

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];
于 2011-08-27T15:21:05.083 回答