I have a question about Alamofire.
我有个关于阿拉莫菲尔的问题。
I'm doing this:
我这样做:
var mutableURLRequest = NSMutableURLRequest(URL:url!)
mutableURLRequest.setValue(response!.allHeaderFields["TOKEN"] as! String, forHTTPHeaderField: "X-AUTH-TOKEN")
mutableURLRequest.HTTPMethod = "GET"
let manager = Alamofire.Manager.sharedInstance // or create a new one
let request = manager.request(mutableURLRequest)
request.responseJSON { (request, response, string, error) in
println(response!.statusCode)
println(string!)
}
When I print string the output is JSON. I want to search for a single element (f.e. username or something else) in that JSON response.
当我打印字符串时,输出是JSON。我希望在JSON响应中搜索单个元素(f.e.用户名或其他元素)。
How can I do that?
我怎么做呢?
Thank you and best regards,
谢谢,并致以最诚挚的问候。
Alban Veliu
奥尔本Veliu
1 个解决方案
#1
1
You can do it in Swift, but IMHO it's a lot easier using the SwiftyJSON framework. It has an excellent tutorial and documentation and you should be up an running in no time : https://github.com/SwiftyJSON/SwiftyJSON
您可以在Swift中完成,但是使用Swift json框架要容易得多。它有一个优秀的教程和文档,您应该很快就能运行:https://github.com/SwiftyJSON/SwiftyJSON
#1
1
You can do it in Swift, but IMHO it's a lot easier using the SwiftyJSON framework. It has an excellent tutorial and documentation and you should be up an running in no time : https://github.com/SwiftyJSON/SwiftyJSON
您可以在Swift中完成,但是使用Swift json框架要容易得多。它有一个优秀的教程和文档,您应该很快就能运行:https://github.com/SwiftyJSON/SwiftyJSON