【发布时间】:2018-07-04 09:56:53
【问题描述】:
大家好,我一直在尝试将这个 Objective-c 代码转换为 swift,但一直在遇到问题。这是objective-c代码:
int msgLength = *((int *) _inputBuffer.bytes);
msgLength = ntohl(msgLength);
这是我设法得到的:
var msgLength = (inputBuffer.bytes).load(as: Int.self)
msgLength = Int(NSSwapBigLongToHost(UInt(msgLength)))
但这不起作用,它崩溃说没有足够的位。非常感谢您的帮助,谢谢!
【问题讨论】:
标签: objective-c swift byte