How-to: Detect iOS device type

Although Apple doesn’t want you to design your app for a special device in its device list, there always will be sometime you need to know if the device user is using is the one you want to enable/disable some features in your app. iOS SDK provide a UIDevice class for some basic system information like OS version and device type. But if you want to know if it is an iPhone 3GS or iPad 1, you might need some help.

I recently need the kind of information in one of my project. We’d like to provide videos in different quality for different devices. Though the app the same one, the asset will be different for different devices. In order to get the detail device information, I use an extension of UIDevice from GitHub. There is not need to import the entire extension to your project, only the UIDevice-Hardware would be enough.

The extension provides convenient method to get device/platform name. By calling the following API, you will be served with what your want.

[[UIDevice currentDevice] platformString]

Please note that this extension has been updated for at least 6 months, it stil uses iPad3 and iPhone5. You need to update those strings by yourselves.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s