I am trying to make async. request using Promisekit's promises. I have the following code in a subclass of UITableViewController, to reload tableview with data that is fetched from async. request.
my_promise.then { asynly_fetched_data in
self.data = asyncly_fetched_data
self.tableView.reloadData()
}
However, the following statement (self.tableView.reloadData()) is causing the following build error.
Missing return in a closure expected to return 'AnyPromise'
Is it because we cannot call reloadData() inside a closure. IF that is the case, what is the best practice to reload tableview after asynchronous request is complete.
It's a swift bug. But you can fix it by adding -> Void
in your closure:
my_promise.then { asynly_fetched_data -> Void in
self.data = asyncly_fetched_data
self.tableView.reloadData()
}
That way, Swift knows that the return is Void.