1.VC生命周期
A頁(yè)面顯示
loadView -> viewDidLoad->viewWillAppear->viewDidAppear
A頁(yè)面跳轉(zhuǎn)B頁(yè)面
A loadView ->A viewDidLoad->B viewWillDisappear->A viewWillAppear->B viewDidDisappear->A viewDidAppear
B頁(yè)面返回A頁(yè)面
B viewWillDisappear->A viewWillAppear->B viewDidDisappear->A viewDidAppear->B dealloc
2.創(chuàng)建單例 創(chuàng)建.h文件寨辩,定義宏
ifndef XLXSingleton_h
define XLXSingleton_h
// @interface
define singleton_interface(className) \
- (instancetype)shared##className;
// @implementation
define singleton_implementation(className) \
static className *_instance; \
- (instancetype)shared##className
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instance = [[self alloc] init];
});
return _instance;
} \ - (instancetype)allocWithZone:(NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instance = [super allocWithZone:zone];
});
return _instance;
} \
- (instancetype)copyWithZone:(NSZone *)zone{
return _instance;
} \ - (instancetype)mutableCopyWithZone:(NSZone *)zone{
return _instance;
}