Skip to content

Instantly share code, notes, and snippets.

@jontelang
Created July 13, 2014 08:01
Show Gist options
  • Save jontelang/5b2030d7453d5b7e37cc to your computer and use it in GitHub Desktop.
Save jontelang/5b2030d7453d5b7e37cc to your computer and use it in GitHub Desktop.
asd
//
// 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