OC方法参数的传递 实际上就是指针指向的对象(或基本数据类型的值)传递;
//Demo验证
- (void)methodPass
{
Person *per = [[Person alloc] init];
per.age = 18;
NSLog(@“per :%p , %p” , per , &per);
[self run:per];
NSLog(@“per :%p , %p” , per , &per);
// per :0x600001a60170 , 0x7ffee7187138
// per :0x600001a60170 , 0x7ffee7187138
// per变量指向的Person 对象传给了man变量,man是一个新的指针变量,与per指针变量没有关系,且man指针里面存储的也是Person对象的地址。
}
-
(void)run:(Person *)man
{
man.age = 19;
NSLog(@“self :%p , %p” , self , &self);
NSLog(@"_cmd :%p , %p" , _cmd , &(_cmd));
NSLog(@“man :%p , %p” , man , &man);man = [Person new];
NSLog(@“newMan :%p , %p” , man , &man);
// self :0x7fc2efe05860 , 0x7ffee7187118
// _cmd :0x7fff5ee033f9 , 0x7ffee7187110
// man :0x600001a60170 , 0x7ffee7187108
// newMan :0x600001a70000 , 0x7ffee7187108
}