我有以下方法,如果SessionStatus完成,我想返回movieDestinationUrl
,但我不断收到此错误Unexpected non-void return value in void function
。我究竟做错了什么?异步completionHandler内的返回值
func createVideo() -> NSURL {
// create new file to receive data
let docsDir: AnyObject = documentsPath
let movieFilePath = docsDir.stringByAppendingPathComponent("result.mov")
let movieDestinationUrl = NSURL(fileURLWithPath: movieFilePath)
_ = try? NSFileManager().removeItemAtURL(movieDestinationUrl)
// use AVAssetExportSession to export video
let assetExport = AVAssetExportSession(asset: composition, presetName:AVAssetExportPresetHighestQuality)
assetExport!.outputFileType = AVFileTypeQuickTimeMovie
assetExport!.outputURL = movieDestinationUrl
assetExport?.videoComposition = layercomposition
assetExport!.exportAsynchronouslyWithCompletionHandler({
switch assetExport!.status{
case AVAssetExportSessionStatus.Failed:
print("failed \(assetExport!.error)")
case AVAssetExportSessionStatus.Cancelled:
print("cancelled \(assetExport!.error)")
default:
print("Movie complete")
// save to photoalbum
return movieDestinationUrl
}
})
}
这看起来怎么样? –
查看'NSNotificationCenter'的文档。如果使用它后不清楚,让我知道什么部分混淆你。 –