gpt4 book ai didi

objective-c - AssetsLibrary 没有按预期产生故障

转载 作者:行者123 更新时间:2023-11-28 23:14:03 31 4
gpt4 key购买 nike

我有这个代码:

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

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

Could not find photo 1000000141
success

如果这在照片不存在时不显示,我如何才能找到?

最佳答案

解决了!

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];

关于objective-c - AssetsLibrary 没有按预期产生故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7215021/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com