func loadMoreData(offset: Int, completion: (result: [ArtistJSONMapper]?) -> Void) {
var fetchedData = [ArtistJSONMapper]()
let pageNum: Int = offset/paging.limit
// Calling the json fetch to obtain data
JSONFetch.jsonTest() { (fetched, error) -> Void in
if(fetched != nil) {
fetchedData = fetched!
//self.tableView.reloadData()
} else {
println("error - \(error)")
}
}
println("Fetched data count is \(fetchedData.count)")
completion(result: fetchedData.count > 0 ? fetchedData : nil)
}
我正在使用AlamofireObjectMapper使用JSONFetch.jsonTest()方法获取数据。现在的问题是如何从我的控制器调用这个loadMoreData?
答案 0 :(得分:0)
我在这里实现尾随闭包
loadMoreData(2){ (result) in
//after completion of your work this closure gets called
println("your return \(result)")
}