赞
踩
一些公用类:
@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、对象释放<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。