// 单例 #define DECLARE_SHARED_INSTANCE(className) + (className *)sharedInstance; #define IMPLEMENT_SHARED_INSTANCE(className) + (className *)sharedInstance { static className *sharedInstance = nil; @synchronized(self) { if (!sharedInstance) { sharedInstance = [[[self class] alloc] init]; } } return sharedInstance; }
原文:http://www.cnblogs.com/songxing10000/p/4929814.html