In Objective C the following syntax was possible:
NSHTTPURLResponse *response = nil;
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returni
Instead of manually creating an AutoreleasingUnsafeMutablePointer
, you can simply use &
to wrap the value you want to send a pointer to - your code becomes much simpler:
var response: NSURLResponse?
var error: NSError?
let urlData = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: &error)
After the call, you need to cast your response to NSHTTPURLResponse
to access those properties:
if let httpResponse = response as? NSHTTPURLResponse {
println(httpResponse.statusCode)
}