From e2921f7e7c9d86d6abdca41443dd79bd0089a74e Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Wed, 2 Dec 2015 13:33:11 -0800 Subject: [PATCH] refs #3112: cleanups around Core Telephony runtime - don't do anything with CT in simulator - more direct use of dynamic selectors for clarity --- platform/ios/MGLMapboxEvents.m | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index a0f87eeab..239ac7ece 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -76,21 +76,22 @@ const NSTimeInterval MGLFlushInterval = 60; _scale = [UIScreen mainScreen].scale; } +#if !TARGET_OS_SIMULATOR // Collect cellular carrier data if CoreTelephony is linked - Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo"); - if (CTTelephonyNetworkInfo != NULL) { - id telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init]; - + Class MGLTelephony = NSClassFromString(@"CTTelephonyNetworkInfo"); + if (MGLTelephony) { + id telephonyNetworkInfo = [[MGLTelephony alloc] init]; SEL subscriberCellularProviderSelector = NSSelectorFromString(@"subscriberCellularProvider"); - id carrierVendor = ((id (*)(id, SEL))[telephonyNetworkInfo methodForSelector:subscriberCellularProviderSelector])(telephonyNetworkInfo, subscriberCellularProviderSelector); + id carrierVendor = [telephonyNetworkInfo performSelector:subscriberCellularProviderSelector]; // Guard against simulator, iPod Touch, etc. if (carrierVendor) { SEL carrierNameSelector = NSSelectorFromString(@"carrierName"); - NSString *carrierName = ((id (*)(id, SEL))[carrierVendor methodForSelector:carrierNameSelector])(carrierVendor, carrierNameSelector); + NSString *carrierName = [carrierVendor performSelector:carrierNameSelector]; _carrier = carrierName; } } +#endif } return self; }