forked from leehosung/LemonEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LMTutorialManager.m
62 lines (53 loc) · 1.51 KB
/
LMTutorialManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// LMTutorialManager.m
// IUEditor
//
// Created by jd on 7/2/14.
// Copyright (c) 2014 JDLab. All rights reserved.
//
#import "LMTutorialManager.h"
@implementation LMTutorialManager
/**
Show tutorial if that tutorial haven't seen.
@param tutorialID toturialID to show
@note If that tutorial is seen, this function does not do anything.
*/
+ (BOOL)shouldShowTutorial:(NSString*)tutorialID{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"TutorialIgnore"]) {
return NO;
}
NSMutableDictionary *dict = [[[NSUserDefaults standardUserDefaults] objectForKey:@"Tutorial"] mutableCopy];
if (dict == nil) {
dict = [NSMutableDictionary dictionary];
}
BOOL shown = [[dict objectForKey:tutorialID] boolValue];
if (shown) {
return NO;
}
else{
[dict setObject:@(YES) forKey:tutorialID];
[[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"Tutorial"];
return YES;
}
}
/**
Reset all show tutorial history.
*/
+ (void)reset{
[[NSUserDefaults standardUserDefaults] setObject:[NSDictionary dictionary] forKey:@"Tutorial"];
}
/**
Ignore all showTutorial: message.
@note This function is opposite to unIgnore function.
*/
+ (void)ignore{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"TutorialIgnore"];
}
/**
Show tutorial if showTutorial message comes.
@note This function is opposite to ignore function.
*/
+ (void)unIgnore{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"TutorialIgnore"];
}
@end