instancetype和id的区别

来源:互联网 发布:linux下卸载oracle11g 编辑:程序博客网 时间:2024/05/01 16:21
/* instancetype 和 id 都是万能指针,指向对象。 不同点:    1.id在编译的适合不能判断对象的真实类型,instancetype在编译的时候可以判断对象的真实类型    2.id可以用来定义变量,可以作为返回值类型,可以作为形参类型;instancetype只能作为返回值类型  注意:以后凡是自定义构造方法,返回值类型尽量使用instancetype,不要使用id */- (instancetype)init{    self = [super init];    if (self) {        //    }    return self;}

0 0