Max
Max

Reputation: 1349

Get info about current simulator device

As I know if I want to know which type of device is using (iPod, iPhone 4, iPhone 5 etc) I should use (swift):

UIDevice.currentDevice().model

But this code works only with real devices and if working simulator it just says: iPhone simulator. And never mind which type of. How I can get information about currently simulator device?

Upvotes: 1

Views: 147

Answers (1)

savner
savner

Reputation: 840

Check the screen size to determine what device the simulator is running as:

let screenSize: CGRect = UIScreen.mainScreen().bounds
let screenWidth = screenSize.width;
let screenHeight = screenSize.height;

If you want to get the version of the OS etc. you can use UIDevice.currentDevice() to access additional details: https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/systemName

Upvotes: 1

Related Questions