gpt4 book ai didi

swift - swift编码后无法打印数据

转载 作者:行者123 更新时间:2023-11-30 10:16:29 26 4
gpt4 key购买 nike

当我尝试对数据进行编码时,出现以下错误。如果我直接打印而没有正确编码其打印

fatal error :在解包可选值时意外发现 nil

   // get the NSURLRequestSession and get the data
let task = NSURLSession.sharedSession().dataTaskWithRequest(nsurlReq){
(data,response,error) in

// check whether there is no error

if(error==nil)
{


// println("Data \(data) ");
var encodedData = NSString(data: data, encoding: NSUTF8StringEncoding)!;

println(encodedData);


}

} //

// you need to resume the task

task.resume();

最佳答案

我希望您的数据具有无效编码,这就是您无法打印解析数据的原因。

关于swift - swift编码后无法打印数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29717063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com