-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathFunctionTipsManager.m
69 lines (60 loc) · 2.07 KB
/
FunctionTipsManager.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
63
64
65
66
67
68
69
//
// FunctionTipsManager.m
// Coding_iOS
//
// Created by Ease on 15/6/23.
// Copyright (c) 2015年 Coding. All rights reserved.
//
static NSString *kFunctionTipStr_Version = @"version";
#import "FunctionTipsManager.h"
@interface FunctionTipsManager ()
@property (strong, nonatomic) NSMutableDictionary *tipsDict;
@end
@implementation FunctionTipsManager
+ (instancetype)shareManager{
static FunctionTipsManager *shared_manager = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
shared_manager = [[self alloc] init];
});
return shared_manager;
}
- (instancetype)init
{
self = [super init];
if (self) {
_tipsDict = [NSMutableDictionary dictionaryWithContentsOfFile:[self p_cacheFilePath]];
if (![[_tipsDict valueForKey:@"version"] isEqualToString:kVersionBuild_Coding]) {
_tipsDict = [@{kFunctionTipStr_Version: kVersionBuild_Coding,
//Function Need To Tip
// kFunctionTipStr_File_3V: @(YES),
// kFunctionTipStr_Me_Shop: @(YES),
// kFunctionTipStr_TaskTitleViewTap: @(YES),
} mutableCopy];
[_tipsDict writeToFile:[self p_cacheFilePath] atomically:YES];
}
}
return self;
}
- (NSString *)p_cacheFilePath{
NSString *fileName = @"FunctionNeedTips.plist";
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [cachePaths firstObject];
return [cachePath stringByAppendingPathComponent:fileName];
}
- (BOOL)needToTip:(NSString *)functionStr{
NSNumber *needToTip = [_tipsDict valueForKey:functionStr];
if (!needToTip) {
return [functionStr hasPrefix:kFunctionTipStr_StartLinkPrefix];
}else{
return needToTip.boolValue;
}
}
- (BOOL)markTiped:(NSString *)functionStr{
if (![self needToTip:functionStr]) {
return NO;
}
[_tipsDict setValue:@(NO) forKey:functionStr];
return [_tipsDict writeToFile:[self p_cacheFilePath] atomically:YES];
}
@end