I have 2 table controllers and a final detail controller - all the data is supplied by CloudKit. My first table controller is quite slow loading (3-4 seconds) only to produce about 8 table cells - each cell only containing an image and label as seen below. The second table controller is about 2-3 seconds of loading time.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("dining") as! DiningTableCell
let restaurant: CKRecord = categories[indexPath.row]
cell.RestaurantName?.text = restaurant.valueForKey("Name") as? String
let img = restaurant.objectForKey("Picture") as! CKAsset
cell.RestaurantPhoto.image = UIImage(contentsOfFile: img.fileURL.path!)
return cell
}
Anyways, I figure I have two opportunities to create a faster response time. The first being, implementing dispatch(a-sync) or NSOperationQueue (unsure which to use if I’m allowing the user to select a table cell)… but something along the lines of
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("dining") as! DiningTableCell
let restaurant: CKRecord = categories[indexPath.row]
cell.RestaurantName?.text = restaurant.valueForKey("Name") as? String
//NSOperationQueue Function {
let img = restaurant.objectForKey("Picture") as! CKAsset
cell.RestaurantPhoto.image = UIImage(contentsOfFile: img.fileURL.path!)
// }
return cell
}
or converting the first table controller into on device app data and then have the second table controller and detail controller load in the background.
Would implementing a background process with all CloudKit data or loading in the background of the first table controller (of on device data) be more effective?