Basic information on iOS access devices

Source: Internet
Author: User

In development sometimes we need to know some basic information about the current device, such as: iphone or ipad, phone model, etc., Apple provides us with the Uidevice class, which provides some important properties related to the device, we can learn some details of the system.

The Uidevice class is designed to be a singleton class that is easy to share and not wasteful to use. How to use: [Uidevice Currentdevice] obtains the Uidevice Singleton and then accesses its properties.

Common Properties:

SystemName------Get the name of the operating system

Systemversion-------Get the version of the current system

Model------Get the type of device

USERINTERFACEIDIOM------The interface style of the device. (For now, it's iphone,ipad/ipod touch)

Name-------The names of the devices in itunes

Simple case:

A project needs to develop the iphone and ipad version, the project analysis found that the difference is only in the interface layer, business logic, data model, and so on, so build a project, only in the V,C layer to do a different treatment on the line. At this point, you need to determine the current device.

Common practices define a macro to use

#define IS_IPAD (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)

Ui_user_interface_idiom () is a very convenient macro in Uikit, its internal implementation is implemented with the Uidevice class, to distinguish the current device

Basic information on iOS access devices

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.