我在swift中将NSData转换为NSString时遇到问题.我正在使用我认为正确的命令和格式:NSString(data: <DATA>, encoding: <ENCODING>)但无论我做什么,我总是以零值结束.我正在运行最新的Xcode测试版,所以我不确定这是否相关,但我希望这是一个简单的错误,我遇到了.
我附上了游乐场代码和屏幕截图.
import Foundation
//: # NSData to String Conversion Playground
//: ### Step 1
//: The first step is to take an array of bytes and conver them into a NSData object. The bytes are as follows:
var testBytes : [UInt8] = [0x14, 0x00, 0xAB, 0x45, 0x49, 0x1F, 0xEF, 0x15, 0xA8, 0x89, 0x78, 0x0F, 0x09, 0xA9, 0x07, 0xB0, 0x01, 0x20, 0x01, 0x4E, 0x38, 0x32, 0x35, 0x56, 0x20, 0x20, 0x20, …Run Code Online (Sandbox Code Playgroud)