美文网首页
oc编译器原生与编译器的模拟代码转换

oc编译器原生与编译器的模拟代码转换

作者: isaaczcbj | 来源:发表于2018-08-24 11:27 被阅读14次

 id obj = [[NSObject alloc]init];

编译器模拟代码:

//    id obj = objc_msgSend(NSObject,@selector(alloc));

//    objc_msgSend(obj,@selector(init));

//    objc_release(obj);

    NSMutableArray *array= [[NSMutableArray alloc]init];

编译器模拟代码:

//    id obj = objc_msgSend(NSMutableArray,@selector(alloc));

//    objc_msgSend(obj,@selector(init));

//    objc_autoreleaseReturnValue(obj);

 NSMutableArray *array2 = [NSMutableArray array];

编译器模拟代码:

//    id obj = objc_msgSend(NSMutableArray,@selector(array2));

//    objc_retainAutoreleasedReturnValue(obj);

//    objc_release(obj);

 id __weakobj1 = obj;

编译器模拟代码:

//    id obj1;

//    objc_initWeak(&obj1,obj);

//    objc_destroyWeak(&obj1);

id__weakobj  = [[NSObject alloc]init];

编译器模拟代码:

//    id obj;

//    id temp = objc_msgSend(NSObject,@selector(alloc));

//    objc_msgSend(temp,@selector(init));

//    objc_initWeak(&obj,temp);

//    objc_release(temp);

//    objc_destoryWeak(obj);

   NSObject*obj = [[NSObject alloc]init];

    [objmethod:10];

编译器模拟代码:

//    NSObject *obj = objc_msgSend(objc_getClass("NSObject"),sel_registerName("alloc"));

//    obj = objc_msgSend(obj,sel_registerName("init"));

//    objc_msgSend(obj,sel_registerName("method:"),10);

相关文章

网友评论

      本文标题:oc编译器原生与编译器的模拟代码转换

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