当前位置:   article > 正文

IOS高级开发~Runtime(一)_ios runtime 疯人院

ios runtime 疯人院

IOS高级开发~Runtime(一)

IOS高级开发~Runtime(二)

IOS高级开发~Runtime(三)

IOS高级开发~Runtime(四)


一些公用类:

@interface CustomClass : NSObject

- (void) fun1;

@end


@implementation CustomClass

- (void) fun1

{

    NSLog(@"fun1");

}

@end


@interface TestClass : NSObject

@end

@implementation TestClass

@end


别忘记引入库:#include<objc/runtime.h>


1、对象拷贝:id object_copy(id obj, size_t size)

- (void) copyObj

{

    CustomClass *obj = [CustomClassnew];

    NSLog(@"%p", &obj);

    

    id objTest = object_copy(obj,sizeof(obj));

    NSLog(@"%p", &objTest);


    [objTest fun1];

}

打印结果:

2013-07-26 15:35:11.547 HighOC[6859:c07] 0xbfffdf64

2013-07-26 15:35:11.547 HighOC[6859:c07] 0xbfffdf60

2013-07-26 15:35:11.547 HighOC[6859:c07] fun1


说明:

object_copy 函数实现了对象的拷贝。

2、对象释放<

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/1022499?site
推荐阅读
  

闽ICP备14008679号