ShopView类
#import "ShopView.h"
@implementation ShopView
- (instancetype)init{
self = [super init];
if (self != nil) {
NSLog(@"%s",__func__);
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self != nil) {
NSLog(@"%s",__func__);
}
return self;
}
@end
init 方法内部会调用initWithFrame:方法
ShopView *shopView = [[ShopView alloc] init];
打印结果
viewControll生命周期[946:54524] -[ShopView initWithFrame:]
viewControll生命周期[946:54524] -[ShopView init]
initWithFrame:方法内部不会调用init 方法
ShopView *shopView = [[ShopView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
打印结果
viewControll生命周期[975:57255] -[ShopView initWithFrame:]