如何将字节转换为字符串? [英] How to convert Byte to String?
本文介绍了如何将字节转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将我的 Byte
转换为 String
因为
I need to convert my Byte
to a String
because
- (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)
接受一个 String
作为它的第一个参数.
takes a String
as its first parameter.
我想要的:
func sendMessage(message: Byte) -> Int {
return outputStream!.write(message, maxLength: 1)
}
推荐答案
你不必提供字符串,但UnsafePointer
.只需在 message
前面加上 &
:
You don't have to provide string, but UnsafePointer<UInt8>
. Just prepend message
with &
:
return outputStream!.write(&message, maxLength: 1)
这篇关于如何将字节转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文