簡體   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