我需要刪除iOS7上的系統照片,這是我的代碼,但不工作ios7刪除照片不起作用
Photos.framework只支持iOS8以上。
ALAssetsLibrary *lib = [ALAssetsLibrary new];
[lib enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
{
if([[asset valueForProperty:ALAssetPropertyAssetURL] isEqual:assetURLs])
{
[asset setImageData:nil metadata:nil completionBlock:^(NSURL *assetURL, NSError *error)
{
NSLog(@"assetURL : %@",assetURLs);
NSLog(@"Error : %@",error);
}];
}
}];
}
failureBlock:^(NSError *error)
{
NSLog(@"Error : %@",error);
}];
日誌:
assetURL:資產庫://asset/asset.PNG ID = BAEEADAF-A1E6-4DBB-BD5A-07058B671AE2 & EXT = PNG
錯誤:錯誤域= ALAssetsLibraryErrorDomain代碼= -3300「寫入失敗」UserInfo = 0x14edf940 {NSLocalizedDescription =寫入失敗,NSUnderlyingError = 0x14eb7580
「操作無法完成(ALAssetsLibraryErrorDomain錯誤-3300。)」,NSLocali zedFailureReason =有寫這個資產問題,因爲寫入失敗}