func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
NSLog("Received response\(response)")
myResponseData = NSMutableData()
}
func connection(connection: NSURLConnection, didReceiveData data: NSData) {
myResponseData.appendData(data)
}
func connectionDidFinishLoading(connection: NSURLConnection) {
NSLog("\(myResponseData)");
let strData = NSString(data: myResponseData, encoding: NSUTF8StringEncoding)
print("Body: \(strData)", terminator: "")
How can we receive a response from a server and according to that set an alert message, like if the status is success we have to show an alert message
An easy, but not so scalable solution is:
Note that NSURConnection is deprecated in favor of NSURLSession.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.