Last active
August 29, 2015 14:04
-
-
Save calebhicks/227de5f3b7e757a17cc3 to your computer and use it in GitHub Desktop.
Onboard Controller
This file contains hidden or 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
// | |
// NTOnboardController.m | |
// | |
// Created by Caleb Hicks on 7/10/14. | |
// | |
// Readme: Subscribe to the notification for onboardedKey where you want to run something for onboarding. | |
// In your App Delegate or initial view controller, insantiate NTOnboardController and call -checkOnboarded. | |
// NTOnboardController will send the onboardedKey notification if the user has not been onboarded. | |
// | |
// Enjoy! Comment or @calebhicks with questions. | |
// | |
#import "NTOnboardController.h" | |
static NSString *onboardedKey = @"onboardedKey"; | |
@implementation NTOnboardController | |
- (void)checkOnboarded{ | |
if (![[NSUserDefaults standardUserDefaults] boolForKey:onboardedKey]) { | |
NSLog(@"No onboard detected, posting notification named %@ now", onboardedKey); | |
[[NSNotificationCenter defaultCenter] postNotificationName:onboardedKey object:nil]; | |
self.onboarded = YES; | |
} else { | |
NSLog(@"Onboard detected"); | |
} | |
} | |
- (void)setOnboarded:(BOOL)onboarded{ | |
_onboarded = onboarded; | |
[[NSUserDefaults standardUserDefaults] setBool:onboarded forKey:onboardedKey]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment