Permalink
Browse files

enable arc conditionally for synthesize macro

  • Loading branch information...
steipete committed Dec 15, 2011
1 parent b8d69f7 commit 4f317bbdf4d6192cc052f9deebbdee6d1ce81946
Showing with 23 additions and 10 deletions.
  1. +23 −10 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

0 comments on commit 4f317bb

Please sign in to comment.