-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQBasePrecompile.h
More file actions
60 lines (49 loc) · 1.17 KB
/
QBasePrecompile.h
File metadata and controls
60 lines (49 loc) · 1.17 KB
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
//
// QBasePrecompile.h
// QBaseFramework
//
// Created by andy on 9/20/14.
// Copyright (c) 2014 streakq. All rights reserved.
//
#ifndef QBaseFramework_QBasePrecompile_h
#define QBaseFramework_QBasePrecompile_h
//单例宏定义
#define DEFINE_SINGLETON_FOR_HEADER(className) \
\
+ (className *)shared##className;
//#if (!__has_feature(objc_arc)) \
//todo:把【aa new】也放到里面
#define DEFINE_SINGLETON_FOR_CLASS(className) \
\
+ (className *)shared##className { \
static className *shared##className = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
shared##className = [[self alloc] init]; \
}); \
return shared##className; \
}
#undef AS_SINGLETON
#define AS_SINGLETON( __class ) \
+ (__class *)instance;
#undef DEF_SINGLETON
#define DEF_SINGLETON( __class ) \
+ (__class *)instance \
{ \
static dispatch_once_t once; \
static __class * __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[__class alloc] init]; } ); \
return __singleton__; \
}
CG_INLINE void DEBUG_NSLOG (NSString *format, ...)
{
#if DEBUG
va_list args;
va_start(args,format);
if (format != nil)
{
NSLogv(format, args);
}
#endif
}
#endif