iOS開發常用宏定義
阿新 • • 發佈:2017-09-01
face 4.0 zone 定義 sel color type main def
// 加載本地xib
#define kMainBundleLoadXib(xibName) [[[NSBundle mainBundle] loadNibNamed:xibName owner:nil options:nil] lastObject]
單利定義
#pragma mark - 實例定義 #define SingletenInterface + (instancetype)sharedInstance; #pragma mark - 定義單例代碼塊 #define SingletenImpl static id _instace; + (id)allocWithZone:(struct _NSZone *)zone { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _instace = [super allocWithZone:zone]; }); return _instace; } - (id)copyWithZone:(NSZone *)zone { return _instace; } + (instancetype)sharedInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _instace = [[self alloc] init]; }); return _instace; }
iOS開發常用宏定義