Tutorial by Examples

Swift 2 import UIKit extension UIDevice { var modelName: String { var systemInfo = utsname() uname(&systemInfo) let machineMirror = Mirror(reflecting: systemInfo.machine) let identifier = machineMirror.children.reduce("") { identifier, ele...
override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: Selector(("batteryStateDidChange:")), name: NSNotification.Name.UIDeviceBatteryStateDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: Selecto...
UIDevice *deviceInfo = [UIDevice currentDevice]; NSLog(@"Device Name %@", deviceInfo.name); //Ex: myIphone6s NSLog(@"System Name %@", deviceInfo.systemName); //Device Name iPhone OS NSLog(@"System Version %@", deviceInfo.systemVersion); //System Version 9.3...
UIDevice *deviceInfo = [UIDevice currentDevice]; int d = deviceInfo.orientation; deviceInfo.orientation returns an UIDeviceOrientation value which is shown as below: UIDeviceOrientationUnknown 0 UIDeviceOrientationPortrait 1 UIDeviceOrientationPortraitUpsideDown 2 UIDeviceOrientationLandscap...
//Get permission for Battery Monitoring [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; UIDevice *myDevice = [UIDevice currentDevice]; [myDevice setBatteryMonitoringEnabled:YES]; double batLeft = (float)[myDevice batteryLevel] * 100; NSLog(@"%.f",batLeft); int d = myD...
//Enabling the proximity Sensor - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sensorStateMonitor:) name:@"UIDevice...

Page 1 of 1