Title: iOS App’s Performance Tips & Tricks
1iOS Apps Performance Tips Tricks
2iOS Apps Performance Tips Tricks
- When developing an iOS app, its critical that
your app has good performance. Your users expect
it, and it will hurt your reviews if your app
appears unresponsive or slow. However, due to the
limitations of iOS devices this can sometimes be
quite hard to get working quite right. Theres a
lot to keep in mind during development, and its
easy to forget the performance impact of your
decisions. - Tips for iOS Apps Performance
- Use ARC to Manage Memory
- Use a reuseIdentifier Where Appropriate
- Set Views as Opaque When Possible
- Avoid Fat XIBs
- Dont Block the Main Thread
3iOS Apps Performance Tips Tricks
Use ARC to Manage Memory ARC was released with
iOS 5 and it eliminates the most common kind of
memory leaks the forgetful ones. ARC stands for
Automatic Reference Counting, and it
automatically manages the retain/release cycles
in your code, so you dont have to do it
manually. UIView view UIView alloc
init // ... self.view addSubviewview view
release Its tremendously easy to forget the
release call at the end of this code block. ARC
does it for you, automatically and
under-the-hood.
4iOS Apps Performance Tips Tricks
Use a reuseIdentifier Where Appropriate A
common mistake in app development is not setting
the correct reuseIdentifier for UITableViewCells,
for UICollectionViewCells, or even
UITableViewHeaderFooterViews. For maximum
performance, a table view??s data source should
generally reuse UITableViewCell objects when it
assigns cells to rows in tableViewcellForRowAtInd
exPath. A table view maintains a queue or list
of UITableViewCell objects that the data source
has marked for reuse. To use reuseIdentifiers,
call this method from your data source object
when asked to provide a new cell for the table
view static NSString CellIdentifier
_at_"Cell" UITableViewCell cell tableView
dequeueReusableCellWithIdentifierCellIdentifier
forIndexPathindexPath
5iOS Apps Performance Tips Tricks
Set Views as Opaque When Possible If you have
opaque views that is, views that have no
transparency defined you should set their
opaque property to YES. On relatively static
screens, setting the opaque property wont be a
big deal. However, if your view is embedded in a
scroll view, or is part of a complex animation,
not setting this property will definitely impact
the performance of your app! You can also use
the Debug\Color Blended Layers option in the
simulator to see visually what views are not set
as opaque. Your goal should be to make as many of
your views opaque as possible!
6iOS Apps Performance Tips Tricks
Avoid Fat XIBs Storyboards, introduced in iOS
5, are quickly replacing XIBs. However, XIBs are
still useful in some cases. If you need to target
pre-iOS 5 devices, or you have a custom reusable
view, then you cant really avoid them. If
youre forced into using XIBs, make them as
uncomplicated as possible. Try to create one XIB
per view controller, and if possible, break out a
view controllers view hierarchy into separate
XIBs. Note that when you load a XIB into memory,
all of its contents are loaded into memory,
including any images. If you have a view youre
not using immediately, then youre wasting
precious memory. Its worth noting that this
wont happen with storyboards, since a storyboard
will only instantiate a view controller when its
needed.
7iOS Apps Performance Tips Tricks
Dont Block the Main Thread You should never do
any heavy lifting on the main thread. This is
because UIKit does all of its own work on the
main thread, such as drawing, managing touches,
and responding to input. The risk of doing all
of your apps work on the main thread is that if
your code does block this thread, your app will
appear unresponsive. Thats a quick route to
one-star reviews on the App Store. Most cases of
blocking the main thread occur when your app is
performing an I/O operation which involves any
task that needs to read or write from an external
source, such as the disk or the network.
8iOS Apps Performance Tips Tricks
Visit www.iprismtech.com Whatsapp/Call
8885617929 Like facebook.com/iprismtech Tweet
Twitter.com/iprismtech
9iOS Apps Performance Tips Tricks
Thank You For Watching