我用ALIsetsLibrary的writeImageToSavedPhotosAlbum保存照片,在这个方法中我有一个在目标c中的完整块:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:urlString]
completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"Save video fail:%@",error);
} else {
NSLog(@"Save video succeed.");
}
}];
}
但是当我在swift中显示它时,我得到一个对象:
typealias ALAssetsLibraryWriteImageCompletionBlock = (NSURL!, NSError!) -> Void
我只想要获得NSURL 在Swift中我有完成Block的代码:
var imageWriteCompletionBlock: ALAssetsLibraryWriteImageCompletionBlock!
self.completionBlock = {
reason in println(reason)
}
怎么做呢?
谢谢!
答案 0 :(得分:3)
ALAssetsLibrary().writeImageToSavedPhotosAlbum(image.CGImage,
orientation: ALAssetOrientation.fromRaw(image.imageOrientation.toRaw())!,
completionBlock:{ (path:NSURL!, error:NSError!) -> Void in
println("\(path)")
})
的问候,