繁体   English   中英

swift中的uint8_t相当于什么?

[英]What is the equivalent of uint8_t in swift?

在obj-c / c ++框架中有一个方法,它采用uint8_t和常规int

- (bool)push:(uint8_t *)buf length:(int)len;

我使用bridger文件来访问此方法,但是当我使用UInt8Int在swift中调用它时,我收到以下错误:

无法使用类型'(UInt8,length:Int)'的参数列表调用'push'

我怎样才能使它工作?

该方法需要一个指向UInt8类型元素数组和Int32值的指针。 你可以这样做:

var buffer: [UInt8] = [0, 1, 2]
yourObject.push(UnsafeMutablePointer<UInt8>(buffer), length: Int32(buffer.count))

请查看指针应如何处理: https//developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM