-
Notifications
You must be signed in to change notification settings - Fork 1
/
RFKit.h
172 lines (120 loc) · 4.27 KB
/
RFKit.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//
// RFKit.h
// RF
//
// Created by gouzhehua on 14-6-25.
// Copyright (c) 2014年 GZH. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "RFJModel.h"
#define WEAK_SELF(weakSelf) __weak __typeof(&*self)weakSelf = self;
#define DECREASE_COUNT(v) \
((v)>0 ? (--(v)) : 0)
#define VER(a,b,c) \
((a) * 1000000 + (b) * 1000 + (c))
#ifndef IS_IOS6
#define IS_IOS6 ([RFKit iosVer] >= VER(6, 0, 0))
#endif
#ifndef IS_IOS7
#define IS_IOS7 ([RFKit iosVer] >= VER(7, 0, 0))
#endif
#ifndef IS_IOS8
#define IS_IOS8 ([RFKit iosVer] >= VER(8, 0, 0))
#endif
#ifndef IS_IPHONE5
#define IS_IPHONE5 ([RFKit isIPhone5Type])
#endif
#define DICT_ADD_STR(dict, key, value) \
[(dict) setObject:[NSString ifNilToStr:(value)] forKey:(key)]
#define DICT_ADD_INT_STR(dict, key, value) \
[(dict) setObject:[NSString stringWithLongLong:(value)] forKey:(key)]
#define DICT_ADD_FLOAT_STR(dict, key, value) \
[(dict) setObject:[NSString stringWithDouble:(value)] forKey:(key)]
typedef NSMutableArray RFKeyValues;
typedef NSMutableArray RFKeyValue;
#define KVS_ADD_STR(keyValues, key, value) \
[(keyValues) addObject:[NSMutableArray arrayWithObjects:(key), (value), nil]];
#define KVS_ADD_INT(keyValues, key, value) \
[(keyValues) addObject:[NSMutableArray arrayWithObjects:(key), [NSNumber numberWithInteger:(value)], nil]];
#define KVS_ADD_FLOAT(keyValues, key, value) \
[(keyValues) addObject:[NSMutableArray arrayWithObjects:(key), [NSNumber numberWithDouble:(value)], nil]];
#define KV_KEY(keyValue) \
[(keyValue) objectAtIndex:0]
#define KV_VALUE(keyValue) \
[(keyValue) objectAtIndex:1]
#define KV_VALUE_STR(keyValue) \
J2Str([(keyValue) objectAtIndex:1])
#define KV_VALUE_INT(keyValue) \
J2Integer([(keyValue) objectAtIndex:1])
#define KV_VALUE_FLOAT(keyValue) \
J2Float([(keyValue) objectAtIndex:1])
#pragma mark RFKit
@interface RFKit : NSObject
+ (BOOL)isDebugMode;
+ (BOOL)isSimulatorEnv;
+ (NSString *)preferredLanguage;
+ (BOOL)isEnLanguage;
+ (BOOL)isCnLanguage;
+ (NSInteger)verStrToInt:(NSString *)strVer;
+ (NSInteger)iosVer; // XXX.XXX.XXX => XXXXXXXXX 例1.0.1 => 1000001
+ (NSInteger)appVer; // XXX.XXX.XXX => XXXXXXXXX 例1.0.1 => 1000001
+ (BOOL)isIPhone5Type;
+ (void)clearApplicationIconBadgeNumber;
+ (BOOL)isNil:(id)value;
+ (id<NSCoding>)objectWithSerializedObject:(id<NSCoding>)aSerializedObject;
+ (id)loadObjectFromNibName:(NSString *)aNibName class:(Class)aClass;
+ (NSString *)fullVersion;
+ (NSString *)bundleVersion;
+ (NSString *)bundleBuild;
+ (NSString *)bundleIdentifier;
+ (NSString *)bundleDisplayName;
+ (NSString *)bundleName;
+ (NSString *)className:(Class)cls;
+ (NSString *)selectorName:(SEL)aSelector;
+ (id)deepMutableCopyWithJson:(id)json;
+ (NSString *)getUUID;
+ (NSString *)getUUIDNoSeparator;
@end
#pragma mark RFKeyValuePair
@interface RFKeyValuePair : NSObject
{
}
@property (nonatomic, strong) NSString *key;
@property (nonatomic, strong) id value;
- (id)initWithKey:(NSString *)aKey value:(id)aValue;
+ (RFKeyValuePair *)pairWithKey:(NSString *)key str:(NSString *)str;
+ (RFKeyValuePair *)pairWithKey:(NSString *)key num:(int64_t)num;
+ (RFKeyValuePair *)pairWithNumKey:(int64_t)numKey num:(int64_t)num;
@end
#pragma mark NSString (RFKit)
@interface NSString (RFKit)
- (NSString *)trim;
- (NSInteger)charCount;
- (NSString *)stringByURLEncoding;
- (NSString *)stringByURLDecoding;
- (NSString *)stringByFilterSymbols:(NSArray *)symbols;
- (NSString *)stringByTTSFilter;
- (BOOL)isPhone;
- (BOOL)isEmail;
- (CGFloat)heightWithFont:(UIFont *)font width:(CGFloat)width;
- (CGFloat)widthWithFont:(UIFont *)font;
- (NSString *)toMD5;
@end
#pragma mark NSMutableString (RFKit)
@interface NSMutableString (RFKit)
- (void)removeLastChar;
@end
#pragma mark NSDate (RFKit)
@interface NSDate (RFKit)
+ (NSString *)yyyyMMddHHmmssSince1970:(int64_t)millisecond;
- (NSString *)yyyyMMddHHmmss;
+ (NSString *)yyyyMMddSince1970:(int64_t)millisecond;
- (NSString *)yyyyMMdd;
+ (NSString *)yyyyMMddHHmmssTimestampSince1970:(int64_t)millisecond;
- (NSString *)yyyyMMddHHmmssTimestampSince1970;
+ (int64_t)millisecondSince1970;
+ (NSDate *)dateWithMillisecondSince1970:(int64_t)millisecond;
+ (void)modifyTimeWithLocal:(int64_t)local server:(int64_t)server;
+ (NSDate *)dateString:(NSString *)dateString withFormatString:(NSString *)formateString;
@end