Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would move as much of the logic out of <code>cellForRowAtIndexPath:</code> as you can, it needs to be very light-weight to get good scrolling performance. You're doing a lot of work on the main thread, and I would do a lot more of this work when you get your model objects back from Parse (if you could post <code>viewDidLoad</code> I can give you more specific help) and update the table view when these calls are done:</p> <ul> <li><code>[UIImage imageWithData:data]</code></li> <li>anything to do with <code>NSDateFormatter</code></li> <li><code>CLLocation</code>'s <code>initWithLatitude:longitude:</code></li> <li>creating the rating stars image</li> </ul> <p>None of these depend on the state of the table view, so they can be effectively precomputed and cached in a model object. If you simply scroll up and down the table, you're doing allo f the same work over and over, killing your performance.</p> <hr> <p>Updated for the questioner's newest code:</p> <p>I won't include all of your functionality here but this should give you an idea:</p> <pre><code>// create a single shared formatter instead of one per object NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatFromTemplate:@"dd/MM" options:0 locale:[NSLocale currentLocale]]; NSDateFormatter *timeFormatter = [NSDateFormatter dateFormatFromTemplate:@"j:mm" options:0 locale:[NSLocale currentLocale]]; [hours findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { self.objectsNumber = objects.count; for (SomeObject *modelObj in objects) { // if you can add properties to your model object directly, do that // otherwise write a category on the Parse object to add the ones you need modelObj.dateString = [NSString stringWithFormat:@"%@ %@ %@ %@", modelObj.dal, [self.dateFormatter stringFromDate:[modelObj objectForKey:@"startDate"]], modelObj.ore, [self.timeFormatter stringFromDate:[modelObj objectForKey:@"endDate"]]]; // create your locations, images, etc in here too } self.hH = [[NSArray alloc] initWithArray:objects]; } }];] </code></pre> <p>Then in <code>cellForRowAtIndexPath:</code>, take the precomputed properties and simply assign them to the appropriate labels, image views, etc.</p> <p>It would be even better to do most of this processing off the main thread via GCD, but that is most likely out of scope for this question. See <a href="http://nachbaur.com/blog/using-gcd-and-blocks-effectively" rel="nofollow">Using GCD and Blocks Effectively</a> for more information. Just remember do only interact with UIKit from the main thread!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload