Skip to content

Commit 0d10861

Browse files
author
dsward2
committed
In AppDelegate localHostString method, return the best result according to the network interface name. "en0" is the preferred interface, and "en1" is the secondary preference.
Several unneeded Xcode schemes were removed, mostly tests and sample code from third-party libraries.
1 parent 5ec1f8b commit 0d10861

50 files changed

Lines changed: 22 additions & 4344 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LocalRadio/AppDelegate.m

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,15 @@ static int GetBSDProcessList(kinfo_proc **procList, size_t *procCount)
416416
return err;
417417
}
418418

419-
// ================================================================
420419

421420
- (NSString *)localHostString
422421
{
422+
//NSArray * ipAddresses = [[NSHost currentHost] addresses];
423+
//NSArray * sortedIPAddresses = [ipAddresses sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
424+
423425
NSString * hostString = @"error";
426+
NSString * en0HostString = NULL;
427+
NSString * en1HostString = NULL;
424428
struct ifaddrs * interfaces = NULL;
425429
struct ifaddrs * temp_addr = NULL;
426430
int success = 0;
@@ -437,17 +441,34 @@ - (NSString *)localHostString
437441
{
438442
// Get NSString from C String
439443
hostString = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
444+
445+
if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
446+
en0HostString = hostString;
447+
}
448+
if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en1"]) {
449+
en1HostString = hostString;
450+
}
440451
}
441452
temp_addr = temp_addr->ifa_next;
442453
}
443454
}
444455

445456
// Free memory
446457
freeifaddrs(interfaces);
458+
459+
if (en0HostString != NULL)
460+
{
461+
hostString = en0HostString;
462+
}
463+
else if (en1HostString != NULL)
464+
{
465+
hostString = en1HostString;
466+
}
447467

448468
return hostString;
449469
}
450470

471+
451472
// ================================================================
452473

453474
- (NSString *)portString

LocalRadio/CocoaAsyncSocket-7.6.3/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/Mac Framework.xcscheme

Lines changed: 0 additions & 113 deletions
This file was deleted.

LocalRadio/CocoaAsyncSocket-7.6.3/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/iOS Framework.xcscheme

Lines changed: 0 additions & 99 deletions
This file was deleted.

LocalRadio/CocoaAsyncSocket-7.6.3/CocoaAsyncSocket.xcodeproj/xcshareddata/xcschemes/tvOS Framework.xcscheme

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)