Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift3 如何使用alamofire处理swift 3中的字符串响应_Swift3_Alamofire - Fatal编程技术网

Swift3 如何使用alamofire处理swift 3中的字符串响应

Swift3 如何使用alamofire处理swift 3中的字符串响应,swift3,alamofire,Swift3,Alamofire,我正在尝试点击url,其响应为: “DBDG96T7331E150600836BC5DC026CC1649A887FC8B921B611172DB39D03566A944946E3CD13246901128413C3C9673D4E806A4V7J2YXE” 那么我如何从响应中处理这个字符串呢?这是我的密码: temp = "Resident|" + user_uid let url = "http://api.appname.my/encodedecode.php?text=\

我正在尝试点击url,其响应为:

“DBDG96T7331E150600836BC5DC026CC1649A887FC8B921B611172DB39D03566A944946E3CD13246901128413C3C9673D4E806A4V7J2YXE”

那么我如何从响应中处理这个字符串呢?这是我的密码:

    temp = "Resident|" + user_uid
    let url = "http://api.appname.my/encodedecode.php?text=\(temp)"
    Alamofire.request(url).responseJSON { (responseObject) -> Void in
        print(responseObject)
    }
作为回应,我得到以下信息:

失败:invalidURL(“”)

管道(
|
)需要在URL中转义

temp = ("Resident|" + user_uid).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
Alamofire.request
可能需要一个真正的
URL
对象

let url = URL(string: "http://api.appname.my/encodedecode.php?text=\(temp)")!