-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathYCFirstTime.h
78 lines (67 loc) · 2.42 KB
/
YCFirstTime.h
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
70
71
72
73
74
75
76
77
78
//
// YCFirstTime.h
// YU - YUPPIU
//
// Created by Fabio Knoedt on 28/08/14.
// Copyright (c) 2014 Fabio Knoedt. All rights reserved.
//
#import <Foundation/Foundation.h>
/*!
* A lightweight library to execute Objective-C codes only once in app life or version life. Execute code/blocks only for the first time the app runs, for example.
*/
@interface YCFirstTime : NSObject
/*!
* Singleton instance shared for the app session.
* @return the initialized object.
*/
+ (YCFirstTime *)shared;
/*!
* Execute a block only once.
* @param blockOnce The block to be executed.
* @param blockKey The unique name of the block.
*/
- (void)executeOnce:(void (^)(void))blockOnce
forKey:(NSString *)blockKey;
/*!
* Execute a block only once.
* @param blockOnce The block to be executed only once.
* @param blockAfterFirstTime The block to be executed always.
* @param blockKey The unique name of the block.
*/
- (void)executeOnce:(void (^)(void))blockOnce executeAfterFirstTime:(void (^)(void))blockAfterFirstTime
forKey:(NSString *)blockKey;
/*!
* Execute a block only once per version.
* @param blockOnce The block to be executed only once.
* @param blockKey The unique name of the block.
*/
- (void)executeOncePerVersion:(void (^)(void))blockOnce
forKey:(NSString *)blockKey;
/*!
* Execute a block only once per version.
* @param blockOnce The block to be executed only once.
* @param blockAfterFirstTime The block to be executed always.
* @param blockKey The unique name of the block.
*/
- (void)executeOncePerVersion:(void (^)(void))blockOnce
executeAfterFirstTime:(void (^)(void))blockAfterFirstTime
forKey:(NSString *)blockKey;
/*!
* Execute a block only once.
* @param blockOnce The block to be executed only once.
* @param blockKey The unique name of the block.
* @param days The number of days that the code should be executed again.
*/
- (void)executeOncePerInterval:(void (^)(void))blockOnce
forKey:(NSString *)blockKey
withDaysInterval:(float)days;
/*!
* Check if a block was executed already or not.
* @param blockKey The unique name of the block.
*/
- (BOOL)blockWasExecuted:(NSString *)blockKey;
/*!
* Resets/Erases all the previous executions.
*/
- (void)reset;
@end