Performance Considerations for iOS Apps - dummies

Performance Considerations for iOS Apps

Improving performance is a main consideration for iOS application developers. Most programmers follow the steps below to create effective apps that function seamlessly while drawing less power.

  • Reduce the amount of memory used by your app by creating only necessary objects, eliminating memory leaks, and using small images and resources. The amount of free memory available and the performance of your app are strongly correlated.

    You can use Instruments to help quantify memory use as well as to find leaks.

  • Reduce power consumption by optimizing your app’s use of the CPU, networking, location, and sensor services. Try not to use polling when you check for data or the status of an operation. Instead, set up a listener in a separate thread that will notify you when the data is available or when the status changes. Also turn off the sensors when they aren’t needed.

  • Connect to external servers only when needed, transmit the smallest amount of data needed, and use compact data formats (JSON rather than XML). Transmit data in bursts.

  • The main thread is where your app handles touch events and other user input. Creating separate threads to perform long-running or potentially unbounded tasks leaves the main thread free to continue processing user input.

  • Modify your code to use floating-point math wherever possible. Hardware-based floating-point computations are typically much faster than their software-based fixed-point equivalents.

  • Apple provides a service called iCloud to which users can back up the data of their apps. You can configure your app to back up to iCloud. Because backing up to iCloud is a time-, network- and energy-consuming operation, ensure that your app handles backing up to iCloud as efficiently as possible.

    You do so by placing temporary files in specific directories where temporary files are supposed to be written (that is, <Application-Home>/Library/Caches and <Application-Home>/tmp). Files in these locations aren’t backed up to iCloud.