我正在将文件从服务器保存到 ALAssetLibrary,以便用户可以在离线模式下查看它
但是我不希望用户多次下载单个文件以避免在相册应用程序中创建重复文件。
那是我的代码:
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
void (^completionBlock)(NSURL *, NSError *) = ^(NSURL *assetURL, NSError *error)
{
if ( error != nil )
{
//writeFailed = YES;
NSLog(@"error = %@", error);
}
//[self notifyCompletionTarget];
NSLog(@" saving is done");
};
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
[library writeVideoAtPathToSavedPhotosAlbum:url completionBlock:completionBlock ];
}