UIDevice Archives

How to check which iOS version your device is running

We can check the UIDevice’s property systemVersion for this. Here’s a quick snippet that checks this, and conveniently checks the first number in the returned value. This should work until iOS 9… NSArray *versionArray = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@”.”]; if ([[versionArray objectAtIndex:0] intValue] >= 7) { // do this if we’re runnign iOS 7 or […]

How to check the battery level of your iOS device?

We can use the batteryLevel property of the UIDevice class for this. It will return a float: float myFloat = [[UIDevice currentDevice] batteryLevel]; If you’d like to print this in a UILabel you’ll have to convert it into a String Object like so: self.myLabel.text = [NSString stringWithFormat:@”%f”, myFloat]; For this to work battery monitoring needs […]