IOS Gets the current device class

Source: Internet
Author: User

. h

// //   GetDevices.h//  1000colors////  Created by HO on 16/6 /12. //   copyright©2016 years HO. All rights reserved. // #import <Foundation/Foundation.h>@interface  getdevices:nsobject+ (nsstring *) devicestring; @end

. m

////GETDEVICES.M//1000colors////Created by HO on 16/6/12.//copyright©2016 years HO. All rights reserved.//#import "GetDevices.h"#import<sys/utsname.h>@implementationGetDevices+ (nsstring*) devicestring{structUtsname SystemInfo; Uname (&systemInfo); NSString*devicestring =[NSString stringWithCString:systemInfo.machine encoding:nsutf8stringencoding]; if([devicestring isequaltostring:@"iphone1,1"])return @"IPhone 1G"; if([devicestring isequaltostring:@"iphone1,2"])return @"IPhone 3G"; if([devicestring isequaltostring:@"iphone2,1"])return @"IPhone 3GS"; if([devicestring isequaltostring:@"iphone3,1"])return @"IPhone 4"; if([devicestring isequaltostring:@"iphone4,1"])return @"IPhone 4S"; if([devicestring isequaltostring:@"iphone5,2"])return @"IPhone 5"; if([devicestring isequaltostring:@"iphone3,2"])return @"Verizon IPhone 4"; if([devicestring isequaltostring:@"ipod1,1"])return @"iPod Touch 1G"; if([devicestring isequaltostring:@"ipod2,1"])return @"iPod Touch 2G"; if([devicestring isequaltostring:@"ipod3,1"])return @"iPod Touch 3G"; if([devicestring isequaltostring:@"ipod4,1"])return @"iPod Touch 4G"; if([devicestring isequaltostring:@"ipad1,1"])return @"IPad"; if([devicestring isequaltostring:@"ipad2,1"])return @"IPad 2 (WiFi)"; if([devicestring isequaltostring:@"ipad2,2"])return @"IPad 2 (GSM)"; if([devicestring isequaltostring:@"ipad2,3"])return @"IPad 2 (CDMA)"; if([devicestring isequaltostring:@"i386"])return @"Simulator"; if([devicestring isequaltostring:@"x86_64"])return @"Simulator"; NSLog (@"note:unknown Device type:%@", devicestring); returndevicestring; }@end

IOS Gets the current device class

Related Article

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.