How to get the iOS device name model

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.