我有这段代码:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:albumCopy
resultBlock:^(ALAsset *asset) {
NSLog(@"success");
...
}
failureBlock:^(NSError *error) {
NSLog(@"fail");
...
}];
[library autorelease];
问题在于,当我给它一个不存在的图像时,NSLog会出现:
找不到照片1000000141
成功
如果在照片不存在时不会显示,我怎么才能找到?
答案 0 :(得分: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];