0
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: "")
我們如何能夠從服務器接收響應,並根據所設定的警報消息,就像如果狀態是成功,我們必須顯示一條警告消息如何在swift中接收服務器的響應?
在哪個委託方法中我應該收到迴應?你能簡單解釋一下嗎? –
我編輯了我的答案給你更多的細節。如果你需要實際的代碼,你可以在網上找到大量的例子。 – Joride