Created
July 13, 2014 08:01
-
-
Save jontelang/5b2030d7453d5b7e37cc to your computer and use it in GitHub Desktop.
asd
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
// | |
// Problem | |
// Creating a 'UIWindow' object in %ctor does not work | |
// | |
// | |
// Solution 1 | |
// | |
static void createListener() | |
{ | |
IT = [[InstaTogglesWindow alloc] init]; | |
[[LAActivator sharedInstance] registerListener:IT forName:@"com.jontelang.instatoggles"]; | |
} | |
%ctor | |
{ | |
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, (CFNotificationCallback)createListener, (CFStringRef)UIApplicationDidFinishLaunchingNotification, NULL, CFNotificationSuspensionBehaviorCoalesce); | |
} | |
// | |
// Solution 2 | |
// | |
@interface InstaTogglesWindowManager : NSObject | |
-(void)create; | |
@end | |
@implementation InstaTogglesWindowManager | |
-(void)create{ | |
IT = [[InstaTogglesWindow alloc] init]; | |
[[LAActivator sharedInstance] registerListener:IT forName:@"com.jontelang.instatoggles"]; | |
} | |
@end | |
%ctor | |
{ | |
InstaTogglesWindowManager *ITM = [[InstaTogglesWindowManager alloc] init]; | |
[[NSNotificationCenter defaultCenter] addObserver:ITM selector:@selector(create) name:UIApplicationDidBecomeActiveNotification object:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment