Skip to content

Instantly share code, notes, and snippets.

@DHowett
Last active December 16, 2015 21:09
Show Gist options
  • Select an option

  • Save DHowett/5497730 to your computer and use it in GitHub Desktop.

Select an option

Save DHowett/5497730 to your computer and use it in GitHub Desktop.

Revisions

  1. DHowett revised this gist May 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Tweak.xm
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
    }

    - (void)_applicationDidBecomeActive {
    - (void)_applicationDidBecomeActive:(NSNotification *)notification {
    // explode or whatever
    }
    @end
  2. DHowett created this gist May 1, 2013.
    29 changes: 29 additions & 0 deletions Tweak.xm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    @interface MyAwesomeSingletonPleaseDontNameMeThis: NSObject
    + (id)sharedInstance;
    - (void)registerForNotifications;
    @end

    @implementation MyAwesomeSingletonPleaseDontNameMeThis
    + (id)sharedInstance {
    static id _sh;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    _sh = [[self alloc] init];
    });
    return _sh;
    }

    - (void)registerForNotifications {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
    }

    - (void)_applicationDidBecomeActive {
    // explode or whatever
    }
    @end

    %ctor {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [[MyAwesomeSingletonPleaseDontNameMeThis sharedInstance] registerForNotifications];
    [pool drain];
    }