How to get iPhone model from code. (e.g. MC143C)

I need to get the iPhone model number from the code. I can see the model number from my iPhone, which is "MC143C", but when I get this using the code, it returns "iPhone". This is the code that I use to get the model number.

NSLog(@"model: %@", [[UIDevice currentDevice] model]); 

Can someone help me get the information I want to get from my device.

Thanks, ! Zaq

+1
source share
3 answers

import https://github.com/erica/uidevice-extension

1. determine the model number in UIDevice-IOKitExtensions.h

 - (NSString *) modelnumber; 

2. add the following code to UIDevice-IOKitExtensions.m

 - (NSString *) modelnumber{ NSArray *results = getValue(@"model-number"); if (results){ NSString *mn=[[results objectAtIndex:0] copy]; return mn; } return nil; } 
+4
source

As usual, if some information cannot be found in a document, it uses a private API.

In this case, Preferences.app uses IAP.framework to get the information.

+1
source

I'm not sure if you have a specific use case, but look at this: http://github.com/ars/uidevice-extension

He will give you almost all the necessary information. Not the exact model number, but you can get the base model (iPhone 3G) and all its features as the value of ORed enumerations.

+1
source

Source: https://habr.com/ru/post/917450/


All Articles