New value is only available in sendAsynchronousRequest - Swift

后端 未结 2 2109
没有蜡笔的小新
没有蜡笔的小新 2021-01-25 09:35
var arrayData: [String] = []

let bodyData = \"parameter=test\"

let URL: NSURL = NSURL(string: \"Link to php file\")
let request:NSMutableURLRequest = NSMutableURLReque         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-25 09:55

    sendAsynchronousRequest is, as the name suggests, asynchronous. So your final println runs before the request is complete. After the completion handler runs, the new data will be available for all readers (in or outside this handler).

提交回复
热议问题