Getting Device Information

One of the basic ways to interact with the hardware on the device is to retrieve data about the device itself. In iOS, the device is represented by the UIDevice class, which contains information about the device itself, such as its assigned name, operating system version, and device model (iPad, iPhone, iPod touch). The class also can tell you the orientation of the device (portrait and landscape) and provide status on the battery and the proximity sensor (whether the phone is close to the face of the user).

Listing 14.1 shows some of the ways you can use the UIDevice class. Later sections in this chapter contain other examples of interacting with this data.

Listing 14.1 Getting Information About the Current Device ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.