1 arc 下不能用 非arc下确实强大
id object_copy(id obj, size_t size);
Singleton *sigle = [Singleton shareInstance];
sigle.name = @"XXXX";
Singleton *sig2 = object_copy(sigle, sizeof([Singleton class]));
sig2.name = @"AAAAA";
NSLog(@"==:%@",sig2.name);
NSLog(@"==:%@",sig.name);
2 --------------------------------------------------
arc 下不能使用
Ivar object_setInstanceVariable(id obj, const char *name, void *value);
Ivar object_getInstanceVariable(id obj, const char *name, void **outValue);
3------------------------------------------------
//注意这里没有使用getset方法所以getset方法里的属性设置也是无效的
id object_getIvar(id obj, Ivar ivar);
int obj = object_getIvar(aClass, ivar);
NSLog(@"obj=:%d",obj);
void object_setIvar(id obj, Ivar ivar, id value);
4-------------------------------------------------
const char * object_getClassName(id obj);
Class object_setClass(id obj, Class cls);//KVO 用到了
网友评论