Created
February 22, 2014 08:20
-
-
Save keicoder/9150439 to your computer and use it in GitHub Desktop.
objective-c : handleFirstTime
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
| //handleFirstTime | |
| //in DataModel.m | |
| - (void)registerDefaults { | |
| NSDictionary *dictionary = @{ | |
| @"ChecklistIndex" : @-1, | |
| @"FirstTime" : @YES | |
| }; | |
| [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; | |
| } | |
| - (void)handleFirstTime { | |
| BOOL firstTime = [[NSUserDefaults standardUserDefaults] boolForKey:@"FirstTime"]; | |
| if (firstTime) { | |
| Checklist *checklist = [[Checklist alloc] init]; | |
| checklist.name = @"List"; | |
| [self.lists addObject:checklist]; | |
| [self setIndexOfSelectedChecklist:0]; | |
| [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"FirstTime"]; | |
| } | |
| } | |
| //call method | |
| - (id)init { | |
| if ((self = [super init])) { | |
| [self registerDefaults]; | |
| [self handleFirstTime]; | |
| } | |
| return self; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment