本文介绍了将UnsafeMutableRawPointer转换为UnsafeMutablePointer< T>迅速3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码
let grayData = UnsafeMutablePointer<UInt8>(other: malloc(width * height * sizeof(UInt8)))
哪些不能在Swift 3中进行编译?我该如何解决?
Which doesn't compile in Swift 3. How do I fix this?
推荐答案
在您的情况下,最好使用allocate(capacity:)
方法.
In your case, you'd better use allocate(capacity:)
method.
let grayData = UnsafeMutablePointer<UInt8>.allocate(capacity: width * height)
这篇关于将UnsafeMutableRawPointer转换为UnsafeMutablePointer< T>迅速3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!