0
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)

}

I am using AlamofireObjectMapper to fetch data using the method JSONFetch.jsonTest(). Now the problem is how do I call this loadMoreData from my controller?

LC 웃
  • 18,888
  • 9
  • 57
  • 72
Prashant Khanal
  • 249
  • 2
  • 11

1 Answers1

0

I do implementing trailing closure here

loadMoreData(2){ (result) in

//after completion of your work this closure gets called
 println("your return \(result)")


}
LC 웃
  • 18,888
  • 9
  • 57
  • 72
  • Thanks I figured it out before you commented. :) loadMoreData(offset, completion: { (fetched) -> Void in if let fetchedData = fetched { println("Fetched Data\(fetchedData.count)") completion(fetchedData) } }) I did it using like this – Prashant Khanal Aug 04 '15 at 06:29