判断当前是否是wifi网络 BOOL IsWIFIConnection { BOOL ret = YES; struct ifaddrs * first_ifaddr, * current_ifaddr; NSMutableArray* activeInterfaceNames = [[NSMutableArray alloc] init]; getifaddrs( &first_ifaddr ); current_ifaddr = first_ifaddr; while( current_ifaddr!=NULL ) { if( current_ifaddr->ifa_addr->sa_family==0x02 ) { [activeInterfaceNames addObject:[NSString stringWithFormat:@"%s", current_ifaddr->ifa_name]]; } current_ifaddr = current_ifaddr->ifa_next; } ret = [activeInterfaceNames containsObject:@"en0"] || [activeInterfaceNames containsObject:@"en1"]; [activeInterfaceNames release]; return ret; } 判断是否链接到网络