Because of the need to get the name of the device, find some methods on the Internet, found that can solve the problem, but need to do a match, and then the equipment will be a new year, and a lot of equipment, so after acquiring equipment information I did an operation,--"I found a website on Google, Found that this site has to maintain some of this device information, and the condition of the query is that we get from the iOS system machine value, and then do a simple string interception. ~ Results The device name gets to ... , although the method is not very insurance, but can use ... (Note: This is sure to do some exception handling.) )
#import "IOSModelGetter.h"
#import <sys/utsname.h>
@implementation Iosmodelgetter
+ (void) Getdevicemodel: (void (^) (NSString *)) successblock{
struct Utsname systemInfo;
Uname (&systeminfo);
NSString *devicemodel = [NSString stringWithCString:systemInfo.machine encoding:nsutf8stringencoding];
NSString *requesturl = [NSString stringwithformat:@ "https://ipsw.me/iPhone3,1"];
NSData *data = [[NSData alloc] Initwithcontentsofurl:[nsurl Urlwithstring:requesturl]];
NSString *str = [[NSString alloc] Initwithdata:data encoding:nsutf8stringencoding];
Nsrange range1 = [str rangeofstring:@ "<title>"];
Nsrange range2 = [str rangeofstring:@ "Information"];
NSString *desc = [str substringwithrange:nsmakerange (Range1.location+range1.length, range2.location)];
desc = [desc substringtoindex:[desc rangeofstring:@ "information"].location];
}
@end
How to get the iOS device name model