modify mac out file

This commit is contained in:
chuanweizhang2013 2014-06-25 19:33:38 +08:00
parent 90bd722bd2
commit cee5754db4
2 changed files with 7 additions and 2 deletions

View File

@ -1243,6 +1243,7 @@
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
CONFIGURATION_BUILD_DIR = ../../../runtime/mac;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = mac/Prefix.pch;

View File

@ -21,8 +21,12 @@ string getIPAddress()
if (cursor->ifa_addr->sa_family == AF_INET && (cursor->ifa_flags & IFF_LOOPBACK) == 0)
{
NSString *name = [NSString stringWithUTF8String:cursor->ifa_name];
if ([name isEqualToString:@"en0"]) // Wi-Fi adapter
return [[NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)cursor->ifa_addr)->sin_addr)]UTF8String];
if ([name rangeOfString:@"en" options:NSCaseInsensitiveSearch].length > 0) {
string ipaddr = [[NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)cursor->ifa_addr)->sin_addr)]UTF8String];
if (!ipaddr.empty()) {
return ipaddr;
}
}
}
cursor = cursor->ifa_next;
}