Skip to content

Instantly share code, notes, and snippets.

@calebhicks
Last active August 29, 2015 14:04
Show Gist options
  • Save calebhicks/227de5f3b7e757a17cc3 to your computer and use it in GitHub Desktop.
Save calebhicks/227de5f3b7e757a17cc3 to your computer and use it in GitHub Desktop.
Onboard Controller
//
// 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