25 Tips and tricks for enhancing the performance of iOS Apps (Advanced) (2)

Source: Internet
Author: User

25 Tips and tricks for enhancing the performance of iOS Apps (Advanced) (2) 2013-04-16 14:56 broken ship House beyondvincentfont Size:T | T

When developing an iOS application, it is critical that your program has good performance. This is also what users expect, if your program runs slow or slow, will incur the user's bad comment. However, due to the limitations of iOS devices, sometimes you want to get good

AD: Network + Offline Salon | Mobile app Mode innovation: give you a reason to do the app >>


25) Try to avoid date formatting
If you have a lot of dates to use NSDateFormatter, you need to be careful. As mentioned in the previous (expensive reuse object), whenever possible, you should try to reuse nsdateformatters.

However, if you need a faster speed, you should use C to parse the date directly instead of NSDateFormatter. Sam Soffes wrote an article that provided some string codes for parsing ISO-8601 format date characters. You simply need to tweak the code to meet your specific needs.

That sounds good--but do you believe there's a better way?

If you can control the format of the date, you can choose Unix Timestamps (http://en.wikipedia.org/wiki/Unix_time). Unix timestamps is a simple integer that represents the number of seconds from the epoch time to the present, usually the new epoch reference time is 00:00:00 UTC on 1 January 1970.

You can easily see this timestamp converted to NSDate, as follows:

    1. -(nsdate*) Datefromunixtimestamp: (nstimeinterval) Timestamp {
    2. return [NSDate Datewithtimeintervalsince1970:timestamp];
    3. }

The above method is faster than the C function!

Note: Many network APIs return timestamps in milliseconds, so it is important to be aware that you need to divide this timestamp by 1000 before passing it to Datefromunixtimestamp.

Go?
Readers interested in program performance optimization are strongly advised to look at the WWDC videos listed below. Before you watch the video, you need to register an Apple ID (you can watch all WWDC2012 videos after registering):

#406: Adopting Automatic Reference counting
#238: IOS App performance:graphics and animations
#242: IOS App performance:memory
#235: IOS App performance:responsiveness
#409: Learning Instruments
#706: Networking Best Practices
#514: OpenGL ES Tools and techniques
#506: Optimizing 2D Graphics and Animation performance
#601: Optimizing Web Content in Uiwebviews and Websites on IOS
#225: Up and running:making a great impression with every Launch
The following videos are from WWDC 2011 and are also useful:

#308: Blocks and Grand Central Dispatch in practice
#323: Introducing Automatic Reference counting
#312: IOS performance and Power optimization with Instruments
#105: Polishing Your app:tips and tricks to improve the responsiveness and performance
#121: Understanding UIKit Rendering

25 Tips and tricks for enhancing the performance of iOS Apps (Advanced) (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.