Event Listener - Better performance adding to row or table?

You must Login before you can answer or comment on any questions.

I have an app that pulls content from a webservice and populates a table, and it seems a little slow (iOS).

The table has about 15 rows for this section, with an image and 3 labels per row. I add an eventlistener on each row to open a details page, but I'm wondering if performance would be better if I added just one to the table itself instead.

Thoughts?

2 Answers

Accepted Answer

Are you calling appendRow() 15 times, or are you calling setData() once? I definitely recommend the latter.

— answered 9 months ago by Jason Priebe
answer permalink
2 Comments
  • ..dont make fun of me, but I had the setData IN my for loop...stupid curly bracket..

    — commented 9 months ago by Josh Lewis

  • It's an easy mistake to make. Glad you found it!

    — commented 9 months ago by Jason Priebe

No doubt about it. Having one singe listener instead of fifteen can't hurt.

Also, don't forget to specify the className property to your rows so iOS knows all your rows have the same layout. Thus improving overall performance.

— answered 9 months ago by Christian Brousseau
answer permalink
2 Comments
  • Yea, I added className, but it doesnt seem to do anything.

    — commented 9 months ago by Josh Lewis

  • I mentioned className just to be sure, but having a single event listener can't hurt that's for sure.

    — commented 9 months ago by Christian Brousseau

Your Answer

Think you can help? Login to answer this question!