我有一些限制,无法使用本机序列化程序或Alamofire。我只对身体(编码图像)和Content-Type = image / jpeg做出回应。这段代码不起作用:
let responseString = response as! String
let data = NSData(bytes: responseString, length: responseString.characters.count)
let image = UIImage(data: data, scale: 1.0) // nil
答案 0 :(得分:2)
您的回复本身就是NSData直接尝试
var image = UIImage(data: response, scale: 1.0)