# Best way to speed up CloudKit Data driven app performance?

**URL:** <https://forums.kodeco.com/t/best-way-to-speed-up-cloudkit-data-driven-app-performance/15564>\
**Category:** Swift\
**Created:** [June 5, 2016, 8:00pm UTC](https://forums.kodeco.com/t/best-way-to-speed-up-cloudkit-data-driven-app-performance/15564 "2016-06-05T20:00:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonpeter](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jonpeter/32/34139_2.png) [@jonpeter](https://forums.kodeco.com/u/jonpeter)\
**Post date:** [June 5, 2016, 8:00pm UTC](https://forums.kodeco.com/t/best-way-to-speed-up-cloudkit-data-driven-app-performance/15564/1 "2016-06-05T20:00:54Z")

</div>

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?
