美文网首页
iOS init初始化

iOS init初始化

作者: 多肉肉 | 来源:发表于2020-01-13 10:52 被阅读0次

1)标准写法

- (id) init

{

    self = [super init];

    if (self) {

    }

    return self;

}

2)非标准写法

- (id) init

{

    if (self = [super init]) {

    }

    return self;

}

3)非标准写法

- (id) init

{

    if (self == [super init]) {

    }

    return self;

}

区别:2)比3)多一个strong引用,所以3)比2)执行效率上要高一些,但标准写法是1)

相关文章

网友评论

      本文标题:iOS init初始化

      本文链接:https://www.haomeiwen.com/subject/vwegactx.html