0
我在斯威夫特是新的,我不能找到解决这个代码:当我建立了它HTTP请求和条件2
func presentationlum() {
let request = NSMutableURLRequest(URL: NSURL(string: "http://raspberrypi.local/etatlum.php")!)
let Session = NSURLSession.sharedSession()
request.HTTPMethod = "GET"
var JsonDict=NSArray()
let dem = Session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
do{
JsonDict = try! NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions(rawValue: 0))as! NSArray
}
print(JsonDict)
})
dem.resume()
if JsonDict[0] as! String == "0"
{
print("it works !")
}
else
{
print("it works to !")
}
}
我有一个“主题1:信号SIGABRT”错误。 服务器只发送一个Json_encode数组,只有0
或1
(例如:["1","0","0","1","0"]
)。 我只想得到这个回应,并对它做条件,但我不能。 请帮忙,谢谢。