Feature Idea for UIKit: UIDeviceCharacteristics

Originator:jaredsinclair.rn
Number:rdar://16487475 Date Originated:April 1, 2014
Status:Open Resolved:
Product:iOS SDK Product Version:All
Classification:Feature Reproducible:Always
 
Though I will probably always regard it as reeking of code smell, I have to admit that there are times when one has to write device-specific logic based on the current device’s hardware identifier. I’m referring to the identifier obtained using `sysctl()`. For example, the iPhone 4S has the identifier `iPhone4,1`.

A good example of a valid case for device-specific code is any app that has custom AirDrop features. For example, OvershareKit (see link below) has to know whether or not the current device support AirDrop when populating the list of available services for a share sheet. Since Apple provides no APIs for checking the availability of AirDrop, our only recourse is to maintain an exhaustive list of all hardware identifiers for devices that support AirDrop.

But AirDrop is only one use case among many. Lots of apps run into situations where code really needs adapt to the capabilities of the current device. Shoehorning the same code into a ever-widening array of devices results in compromised user experiences for either the oldest or the newest devices, or both.

The deeper problem is that basing device-specific logic on hardware identifiers is an indirect solution. What developers really want to know about are the *characteristics* of the current device, not what kind of device it is. This will be even more true if (as?) Apple’s iOS lineup branches into new device categories (cars, TVs, and watches, to name a few).

A better solution would be for Apple to provide a hypothetical `UIDeviceCharacteristics` framework, which would abstract out specific characteristics like graphics performance, brute computing power, hardware features, etc. This way developers could write code that targets stable and meaningful device characteristics, instead of brittle and incomplete lists of device identifiers.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!