基本照搬这里的代码:http://blog.csdn.net/kindazrael/article/details/7917863
改善了对其风格和缩进,减少了代码量,对齐风格是emacs的
#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;                                            \
}