
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to determine the current iPhone model information?
iOS Provides a UIDevice class which has all the information about your iPhone that does not violate any privacy laws Apple has.
Using the UIDevice we can access information like −
UIDevice.current.localizedModel − this returns the localized version of model
UIDevice.current.model − this returns model of current device, e.g. @"iPhone", @"iPod touch"
UIDevice.current.name − this returns the current name of the device in use, e.g. "My iPhone"
UIDevice.current.systemName − this returns the system name e.g. @"iOS"
UIDevice.current.systemVersion − this returns the system version e.g. @"4.0"
UIDevice.current.batteryLevel − this returns the battery level, if it is between 0 to 1, it will return the value otherwise if the state is UIDeviceBatteryStateUnknown it returns -1.0
UIDevice.current.batteryState − this returns the battery state, it has four possible values as per apple APIs
public enum BatteryState : Int { case unknown case unplugged case charging case full }
You can write the above code in View Controller's viewDidLoad and print to see the result.
print(UIDevice.current.model) print(UIDevice.current.localizedModel) print(UIDevice.current.systemVersion)
Which gave the following result while running on an iPhone 7 plus simulator.
iPhone iPhone 12.0
Here is the result and example of how the above code can be used.
- Related Articles
- How to determine device type (iPhone, iPod Touch) with iPhone SDK?
- How to determine device type (iPhone, iPod Touch) with Swift?
- How to determine the current delimiter in MySQL?
- How to get current location provider information in android?
- How to print current package cache directory information in android?
- What is Security Model in information security?
- How to exit iPhone application gracefully?
- Get current time information in Java
- How can Tensorflow be used with pre-trained model to determine the number of batches in the dataset?
- How to detect the screen size of iPhone 5?
- How to make iPhone vibrate using Swift?
- Determine Resistance Plotting Graph Potential Difference versus Current
- How to parse JSON object in iPhone/iOS?
- How to compare two NSDates in iPhone/iOS?
- How to create a WebView in iOS/iPhone?
