Do this if you want the value after you get response.
func getResponse(completionHandler : ((isResponse : Bool) -> Void)) {
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
println(NSString(data: data, encoding: NSUTF8StringEncoding))
stringResponse = NSString(data: data, encoding: NSUTF8StringEncoding) as! String
if stringResponse == "0" {
completionHandler(isResponse : false)
} else if stringResponse == "1" {
completionHandler(isResponse : true)
} else {
completionHandler(isResponse : false)
}
}
}
Now you call it as below from where ever you are calling.
classObject.getResponse {(isResponse) -> Void in
//Do your stuff with isResponse variable.
}