libin (owner)

Revisions

gist: 92604 Download_button fork
public
Public Clone URL: git://gist.github.com/92604.git
Embed All Files: show embed
Check if iPhone is on WIFI #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
}