iOS Development Tips-version comparison

Source: Internet
Author: User

1. Get the current version information of the app

#define Xcodeappversion [[[NSBundle Mainbundle] infodictionary] objectforkey:@ "cfbundleshortversionstring"]

This is the macro definition provided by Umeng statistics, when using Umeng, you need to set the app version information, as shown below,

[Mobclick setappversion:xcodeappversion]; parameter is NSString * Type, custom app version information, if not set, default from Cfbundleversion

2, iOS system version comparison,

#define Ksystemversion [[Uidevice Currentdevice] systemversion]

This macro can get iOS version information, such as 5.0.1 or 5.1, etc.

NSString *currentsystemversion = ksystemversion;if ([currentsystemversion compare:@ "5.1"]! = NSOrderedAscending) {//current iOS version is greater than 5.1}else if ([Currentsystemversion compare:@ "5.0.1"]! = nsorderedascending) {//The current iOS version is greater than 5.0.1}

The nsorderedasceding documentation is explained below,

(the left operand are smaller than the right operand, the parameters on the side are less

This comparison is convenient, not only to compare 5.1 and 6.1, but also to refine the comparison to the 5.1 and 5.0.1 versions. The refinement is due to the fact that there are some differences in the SDK between each iteration, such as avoiding files being backed up to icloud, which are implemented in 5.1 and 5.0.1 different ways.

iOS Development Tips-version comparison

Related Article

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.