Last active
August 29, 2015 14:15
-
-
Save choefele/d59571cfd2841a385e1c to your computer and use it in GitHub Desktop.
How to know at run-time whether your code runs inside an iOS extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSDictionary *extensionInfo = [NSBundle.mainBundle objectForInfoDictionaryKey:@"NSExtension"]; | |
NSString *extensionPointIdentifier = extensionInfo[@"NSExtensionPointIdentifier"]; | |
if ([extensionPointIdentifier isEqualToString:@"com.apple.watchkit"]) { | |
NSLog(@"WatchKit extension"); | |
} else if ([extensionPointIdentifier isEqualToString:@"com.apple.widget-extension"]) { | |
NSLog(@"Widget extension"); | |
} else if (extensionPointIdentifier == nil) { | |
NSLog(@"iOS app"); | |
} else { | |
NSLog(@"Unknown extension type"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment