

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How to determine device type (iPhone, iPod Touch) with iPhone SDK?
- How to determine the current delimiter in MySQL?
- How to determine device type (iPhone, iPod Touch) with Swift?
- How to get current location provider information in android?
- How to print current package cache directory information in android?
- Get current time information in Java
- What is Security Model in information security?
- How can Tensorflow be used with pre-trained model to determine the number of batches in the dataset?
- How to Determine the Electric Motor Load?
- How to exit iPhone application gracefully?
- How to detect the screen size of iPhone 5?
- How to make iPhone vibrate using Swift?
- How to extract the model equation from model object in R?
- How can Tensorflow used with the pre-trained model to compile the model?
- How to get the MAC address of an iOS/iPhone programmatically?