Skip to content

Commit 18a4598

Browse files
committed
Create SharedUser if not yet available
1 parent 444f89e commit 18a4598

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

BitStoreToday/TodayViewController.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ - (NSUserDefaults *)userDefaults {
120120

121121
- (SharedUser *)user {
122122
NSData* data = [[self userDefaults] objectForKey:@"sharedUser"];
123-
return [NSKeyedUnarchiver unarchiveObjectWithData:data];
123+
SharedUser* user = [NSKeyedUnarchiver unarchiveObjectWithData:data];
124+
if (!user) {
125+
user = [[SharedUser alloc] init];
126+
[self saveUser:user];
127+
}
128+
return user;
124129
}
125130

126131
- (void)saveUser:(SharedUser *)user {

0 commit comments

Comments
 (0)