OVER 3000 CUSTOMERS FROM STARTUPS TO LARGE ENTERPRISES

Microsol is the leading full service digital agency with a strong workforce of 87 employees and 14+ years in operations

Blog

iOS Performance Tricks To Make Your App Feel More Performant

Although modern iOS hardware is powerful enough to handle many intensive and complex tasks, the device could still feel unresponsive if you are not careful about how your app performs. In this article, we will look into five optimization tricks that will make your app feel more responsive.
1. Dequeue Reusable Cell

You’ve probably used tableView.dequeueReusableCell(withIdentifier:for:) inside tableView(_:cellForRowAt:) before. Ever wondered why you have to follow this awkward API, instead of just passing an array of cell in? Let’s go through the reasoning of this.

Say you have a table view with a thousand rows. Without using reusable cells, we would have to create a new cell for each row, like this:

 

As you might have thought, this will add a thousand cells to the device’s memory as you scroll to the bottom. Imagine what would happen if each cell contained a UIImageView and a lot of text: Loading them all at once could cause the app to run out of memory! Apart from that, every single cell would require new memory to be allocated during scrolling. If you scroll a table view quickly, a lot of small chunks of memory will be allocated on the fly, and this process will make the UI janky!

To resolve this, Apple has provided us with the dequeueReusableCell(withIdentifier:for:) method. Cell reuse works by placing the cell that is no longer visible on the screen into a queue, and when a new cell is about to be visible on the screen (say, the subsequent cell below as the user scrolls down), the table view will retrieve a cell from this queue and modify it in the cellForRowAt indexPath: method.
Cell reuse queue mechanism
How cell reuse queues work in iOS (Large preview)

By using a queue to store cells, the table view doesn’t need to create a thousand cells. Instead, it needs just enough cells to cover the area of the table view.

Get A Free instant Quote

Please fill the form below and one of your respesentative shall get in touch with you shortly.

    captcha

    WHAT CLIENTS SAY

    We interviewed 7 other web companies before we found you.   Thank You for designing and developing our web site. The site you created is wonderful!  Your professionalism is truly exceptional! Keep up the great work! We will definitely hire you in future.
    Priscilla ChanFounderSpeakers Connect