I am trying to follow a tutorial for interfacing Game Center, that uses the Apple Documentation and Matt Gallagher's "singleton" document.
However, XCode is emitting polite but vehement protests, lodging its complaints as "Data definition has no type or storage class". In other words, it thinks that SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(GameCenterManager);
is a method declaration lacking a type.
Some StackOverflow archaeology brought to my attention a change to XCode.
However, it lets me quite perplexed. Should I really create, deep inside the compiler settings, two entries, one of which is at least 600 characters long, that basically will contain what currently is inside a nice, neat header file?
Follows the source of said header file, written by Matt Gallagher, which would then go into two places:
#define SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(__CLASSNAME__) \
\
+ (__CLASSNAME__ *)shared##__CLASSNAME__; \
+ (void)purgeShared##__CLASSNAME__;
and
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *shared##classname = nil; \
\
+ (classname *)shared##classname \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [[self alloc] init]; \
} \
} \
\
return shared##classname; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [super allocWithZone:zone]; \
return shared##classname; \
} \
} \
\
return nil; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return self; \
} \
\
- (id)retain \
{ \
return self; \
} \
\
- (NSUInteger)retainCount \
{ \
return NSUIntegerMax; \
} \
\
- (void)release \
{ \
} \
\
- (id)autorelease \
{ \
return self; \
}
So, where am I mistaken in my understanding?