I'm building rest queries in SWIFT using NSURLRequest
var request : NSURLRequest = NSURLRequest(URL: url)
var connection : NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: false)!
connection.start()
My question is how to do i get response code out of the response that is returned:
func connection(didReceiveResponse: NSURLConnection!, didReceiveResponse response: NSURLResponse!) {
//...
}
According to Apple: NSHTTPURLResponse
which is a subclass of NSURLResponse
has a status code but I'm not sure how to downcast my response object so i can see the response code.
This doesn't seem to cut it:
println((NSHTTPURLResponse)response.statusCode)
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…