xcode4.5.6,ios6.1 test to determine the current device, and its network status, etc.; A description of the situation that is not detected by Xcode after the device is plugged in

Source: Internet
Author: User

Catalogue [-]

    • First, the judgment equipment
    • Second, determine the network connection status
    • Third, the device does not show the solution
First, the judgment equipment
01 //设备名称
02 return[UIDevice currentDevice].name;
03
04 //设备型号,只可得到是何设备,无法得到是第几代设备
05 return[UIDevice currentDevice].model;
06
07 //系统版本型号,如iPhone OS
08 return[UIDevice currentDevice].systemVersion;
09
10 //系统版本名称,如6.1.3
11 return[UIDevice currentDevice].systemName;
01 //判断是否为iPhone
02 #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
03
04 //判断是否为iPad
05 #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
06
07 //判断是否为ipod
08 #define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])
09
10 //判断是否为iPhone5
11 #define IS_IPHONE_5_SCREEN [[UIScreen mainScreen] bounds].size.height >= 568.0f && [[UIScreen mainScreen] bounds].size.height < 1024.0f
Second, determine the network connection status

1, import systemconfiguration.framework, and #import<systemconfiguration/scnetworkreachability.h>

2. Determine if the equipment is networked

01 + (BOOL)connectedToNetwork{
02     
03     //创建零地址,0.0.0.0的地址表示查询本机的网络连接状态
04     
05     structsockaddr_storage zeroAddress;
06     
07     bzero(&zeroAddress, sizeof(zeroAddress));
08     zeroAddress.ss_len = sizeof(zeroAddress);
09     zeroAddress.ss_family = AF_INET;
10     
11     // Recover reachability flags
12     SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (structsockaddr *)&zeroAddress);
13     SCNetworkReachabilityFlags flags;
14     
15     //获得连接的标志
16     BOOLdidRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
17     CFRelease(defaultRouteReachability);
18     
19     //如果不能获取连接标志,则不能连接网络,直接返回
20     if(!didRetrieveFlags)
21     {
22         returnNO;
23     }
24     //根据获得的连接标志进行判断
25
26     BOOLisReachable = flags & kSCNetworkFlagsReachable;
27     BOOLneedsConnection = flags & kSCNetworkFlagsConnectionRequired;
28     return(isReachable&&!needsConnection) ? YES : NO;
29 }
Third, the device does not show the solution

PS: If the device is plugged in, but Xcode does not display the current device, it is still the status of iOS device, as shown in

Resolution Steps

1. Click on the organizer->devices in the upper right corner of Xcode to see if your device is green, if it is yellow or no lights, it means the device is not connected, please re-insert it again

2. If the device is connected, but still does not display, the system version does not match, if the device is a ios5 system, then Xcode iOS Deployment Target must be 5.0 or above, Xcode can distinguish this device

Select Targets->summary-deployment Target to modify the iOS version number (assuming set to 6.1)

If still not recognized, the version number is also modified to 6.1 under Project->info->ios Deployment target

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.