无法使用类型为'(Int32?)'的参数列表调用类型'UnsafeMutablePointer <int32>'的初始值设定项

时间:2018-03-28 08:42:03

标签: ios swift

我正在尝试将一些方法和ffmpeg指针实现为Swift,但将其转换为Swift有点复杂。这个错误意味着什么?

  

无法使用类型为'(Int32?)'的参数列表调用类型'UnsafeMutablePointer'的初始值设定项?

代码低于

let pictureFrameData = av_malloc(Int(numBytes))
                                var test = frame?.pointee.linesize.0.
                                av_image_fill_arrays(UnsafeMutablePointer(frameRGB?.pointee.data.0),
                                                     UnsafeMutablePointer<Int32>(frame?.pointee.linesize.0)!,
                                                     pictureFrameData,
                                                     frameRGB?.pointee.format,
                                                     frameRGB?.pointee.width,
                                                     frameRGB?.pointee.height,
                                                     1)

错误发生在此行UnsafeMutablePointer<Int32>(frame?.pointee.linesize.0)

1 个答案:

答案 0 :(得分:1)

如果函数需要'UnsafeMutablePointer<Int32>参数 然后,您必须使用Int32&值作为“inout参数”传递:

var linesize: Int32 = ...
av_image_fill_arrays(..., &lineSize, ...)