Is it possible to get the iPhone model and differentiate between iPhone 6 and 6s series through function calls? I want to know if the user has a 6s model or prior to 6 models as the functions that the user can use within my app will differ depending on the iPhone model the user is using.
-
Look at UIDevice: https://github.com/erichoracek/UIDevice-Hardware/blob/master/UIDevice-Hardware.m But why do you want to do this exactly? – Larme Nov 27 '15 at 10:04
-
Or https://github.com/dennisweissmann/DeviceKit for Swift. Disclaimer: I am the owner of that framework. – HAS Nov 27 '15 at 10:31
-
2You should not differ in cause of the device type. Check if the needed functionallity ist provided by this device by using repsonseToSelector for example – Thallius Nov 27 '15 at 10:53
-
@Larme Thank you. We are extrapolating the 3D touch feature on 6s. Though the idea is to keep this functionality available with or without 3D, wanted to know if it's possible to extract iphone family. – Mann Levitt Nov 27 '15 at 11:06
-
Better use: https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/3DTouchAPIs.html#//apple_ref/doc/uid/TP40016543-CH4-SW2 to know is 3D Touch is available or not. For example, maybe Apple will sell an iPhone 7C without 3DTouch, but the 7 will have it. So you can't just rely on the model. – Larme Nov 27 '15 at 11:09
-
@Larme: Thank you for this help. Makes absolute sense. – Mann Levitt Nov 27 '15 at 11:49
-
Please refer this link to differentiate iPhone 6 from 6s through function calls: http://stackoverflow.com/a/8304788/2401116 – Milan Rathod Dec 01 '15 at 12:01
2 Answers
Of course you can. Determining iOS device type is both possible and quite common.
It is done using approved and public methods, and is very legitimate: your app won't risk not being approved because of that.
It is however much cleaner and safer to test if a certain function will work on the user device,by using respondsToSelector rather than trying to enumerate all possible devices which are known to exist.
Apple keeps on adding devices, making sure that your code won't get broken on new devices if you hardcode this kind of test.
respondsToSelector is appropriate when a method was added to an older class or exists only on a newer device, but you want compatibility with older versions and older devices as well. For example:
if ([myObject respondsToSelector:@selector(fancyNewMethod)]) {
[myObject fancyNewMethod]; // newer devices only
} else {
[myObject doTheOldThing]; // older devices
}

- 1,302
- 1
- 17
- 26
You really should not rely on device model detection to know if a feature is available. It's not future-proof and even if 3D Touch is available on the iPhone 6s / 6s Plus, users can disable it in the settings app.
You can check if 3D Touch is available and active using UITraitCollection
: the forceTouchCapability
property is set to UIForceTouchCapabilityAvailable
.
You can access the traitCollection
property in every view controller and view.
Apple recommends to implement the traitCollectionDidChange:
method, because the values can change dynamically (e.g. the user can leave your app, disable/enable 3D Touch in the settings, then go back to your app).
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{
[super traitCollectionDidChange:previousTraitCollection];
// forceTouchCapability is available starting with iOS 9.0
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]) {
if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
// 3D Touch is available AND enabled
} else {
// 3D Touch is either unavailable or disabled
}
} else {
// Before iOS 9.0
}
}
For complete reference, see the Adopting 3D Touch guide from Apple.

- 12,684
- 4
- 46
- 43