やりたくないことの例:
var b = 0
let URL: NSURL = NSURL(string: "[URL to php file]")!
let request:NSMutableURLRequest = NSMutableURLRequest(URL: URL)
request.HTTPMethod = "POST"
request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue())
{
(response, data, error) in
b = 5
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return b //Return 0
}
numberOfRowsInSection では 0 が返されて sendAsynchronousRequest が実行されることはわかっていますが、 sendAsynchronousRequest の後に numberOfRowsInSection 関数を実行する方法はありますか? または、numberOfRowsInSection 関数の前に変数を 5 に等しくするより良い方法はありますか?