ios 在 Swift 中将 void* 传递给 UISaveVideoAtPathToSavedPhotosAlbum [英] ios passing a void* into UISaveVideoAtPathToSavedPhotosAlbum in Swift
问题描述
我是 Swift 的新手.我正在尝试在我的类中使用方法签名:
I'm new to Swift. I'm trying to use the method signature in my class:
func UISaveVideoAtPathToSavedPhotosAlbum(_ videoPath: String!,
_ completionTarget: AnyObject!,
_ completionSelector: Selector,
_ contextInfo: CMutableVoidPointer)
最后一个参数 contextInfo 是 obj-c 中的 void *.
The last argument, contextInfo, is a void * in obj-c.
如果我在 Swift 中传递字典,我会得到一个 NSDictionary
而不是 CMutableVoidPointer
错误的子类型.将不胜感激任何帮助.我不知道如何在 Swift 中传递 void
* 等效参数而不会出现该错误.
I get an NSDictionary
not a subtype of CMutableVoidPointer
error if I pass a dictionary in Swift. Would appreciate any help with this. I don't know how to pass a void
* equivalent argument in Swift without getting that error.
推荐答案
Objective C - Void*
Objective C - Void*
Swift - UnsafeMutablePointer
Swift - UnsafeMutablePointer
...示例
//将视频保存到相机胶卷的调用
// Your call to save video to camera roll
UISaveVideoAtPathToSavedPhotosAlbum(yourVideoPath, self, "video:didFinishSavingWithError:contextInfo:", nil)
//保存视频后的完成处理程序
// Your Completion Handler after video is saved
func video(videoPath: String, didFinishSavingWithError error: NSError, contextInfo info: UnsafeMutablePointer<Void>) {
// your completion code handled here
}
这篇关于ios 在 Swift 中将 void* 传递给 UISaveVideoAtPathToSavedPhotosAlbum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!