2014-09-11 66 views
1

我節省與ALAssetsLibrary的writeImageToSavedPhotosAlbum照片,在這個方法中我有一個compleion塊,在目標C是:如何獲取使用ALAssetsLibrary保存的照片的網址?

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."); 
           } 
          }]; 

}

但當我拿出這在迅速我得到一個對象:

typealias ALAssetsLibraryWriteImageCompletionBlock = (NSURL!, NSError!) -> Void 

我只想得到NSURL 在斯威夫特我對完成這個區塊代碼:

var imageWriteCompletionBlock: ALAssetsLibraryWriteImageCompletionBlock! 

self.completionBlock = { 
      reason in println(reason) 
     } 

這怎麼辦?

謝謝!

回答

3
ALAssetsLibrary().writeImageToSavedPhotosAlbum(image.CGImage, 
     orientation: ALAssetOrientation.fromRaw(image.imageOrientation.toRaw())!,  
    completionBlock:{ (path:NSURL!, error:NSError!) -> Void in 
          println("\(path)") 
        }) 

問候,