2016-09-18 16 views
1

プロジェクトをswift 3.0に更新しようとしていますが、UnsafeMutablePointerに問題があります。'UnsafeMutablePointer' <uint8> 'の初期化子を'(UnsafeMuatableRawpointer?) '型の引数リストで呼び出せません

let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) 
let src_buff = CVPixelBufferGetBaseAddress(imageBuffer!) 
let dataBuffer = UnsafeMutablePointer<UInt8>(src_buff) //error here 

理由:ここ

は私のエラー

Cannot invoke initializer for type 'UnsafeMutablePointer<uint8>' with an argument list of type '(UnsafeMuatableRawpointer?)' 

コードですか?それを修正するには?あなたのバッファ長(安全な)を知っていれば

:無効ポインタ(別名UnsafeMutableRawPointer)からの変換

答えて

3

は、あなたが2つのオプションを持っているスウィフト3に変更されました

let dataBuffer = src_buff?.bindMemory(to: UInt8.self, capacity: len) 

あなたがわからない場合それ:

let dataBuffer = src_buff?.assumingMemoryBound(to: UInt8.self) 
+0

thx !!!出来た! –

関連する問題