IOS obtains information about the current system and detects it on different iOS devices.

Source: Internet
Author: User

Nslog ([[uidevice currentdevice] Name]); // obtain the device name

Nslog ([[uidevice currentdevice] uniqueidentifier]); // obtain the guid

Nslog ([[uidevice currentdevice] systemname]); // obtain the system name

Nslog ([[uidevice currentdevice] systemversion]); // version

Eg.

Float version = [[[uidevice currentdevice] systemversion] floatvalue];

If (version> = 5.0 ){

// IOS Processing

}

Recently, I found it in my project. The coordinates of ios5 and earlier versions (ios4.0.2) are different. The difference is exactly 20 PX. Therefore, use the special processing of the pull surface.

2. As IOS versions become more and more popular, the compatibility problem of program crashes gradually becomes apparent. For example, it may be because some APIs are only used for ios4, and other APIs must be used for processing in ios5. At this time, your code may contain these two versions of the program. However, the xcode version of this program may not have any programming method. At this time, you can avoid this by using the following methods:

# If _ iphone_ OS _version_max_allowed >=50000
// IOS 5
// Ex. if the version to be checked is 4.1, you can use 40100
# Endif

If you want to check whether a class can be used, you can use this method:

Class ios5class = (nsclassfromstring (@ "ciimage "));
If (nil! = Ios5class ){
}

* For Versions later than 4.2, you can use weak linking for query. For example:

If ([ciimage class]) {
}

If you want to check whether a certain selector exists in a class, you can use respondstoselector in the nsobject Protocol example to check the class. For example:

If ([OBJ respondstoselector @ selector (goodbye:]) {
}

From: http://blog.csdn.net/nogodoss/article/details/7187022

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.