Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

enable arc conditionally for synthesize macro

commit 4f317bbdf4d6192cc052f9deebbdee6d1ce81946 1 parent b8d69f7
@steipete authored
Showing with 23 additions and 10 deletions.
  1. +23 −10 Macros/SynthesizeSingleton.h
View
33 Macros/SynthesizeSingleton.h
@@ -12,6 +12,7 @@
// appreciated but not required.
//
+#if __has_feature(objc_arc)
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *shared##classname = nil; \
@@ -21,29 +22,41 @@ static classname *shared##classname = nil; \
static dispatch_once_t pred; \
dispatch_once(&pred, ^{ shared##classname = [[self alloc] init]; }); \
return shared##classname; \
+}
+#else
+#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
+\
+static classname *shared##classname = nil; \
+\
++ (classname *)shared##classname \
+{ \
+static dispatch_once_t pred; \
+dispatch_once(&pred, ^{ shared##classname = [[self alloc] init]; }); \
+return shared##classname; \
} \
- \
- \
+\
+\
- (id)copyWithZone:(NSZone *)zone \
{ \
- return self; \
+return self; \
} \
- \
+\
- (id)retain \
{ \
- return self; \
+return self; \
} \
- \
+\
- (NSUInteger)retainCount \
{ \
- return NSUIntegerMax; \
+return NSUIntegerMax; \
} \
- \
+\
- (oneway void)release \
{ \
} \
- \
+\
- (id)autorelease \
{ \
- return self; \
+return self; \
}
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.