A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© tsc0000 中级黑马   /  2015-11-9 09:22  /  638 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


Heap和stack 地址


源码:
__block int val = 10;
int *p = &val;
NSLog(@"%d address is :%p",val,&val);
block_blk blk = ^{
NSLog(@"%d address is :%p",++val,&val);
return  val;
};
blk();
NSLog(@"%d address is :%p",val,&val);
NSLog(@"%d address is :%p",*p,p);

ARC运行结果:
10 address is :0x7fff5fbff908
11 address is :0x100103578
11 address is :0x100103578
10 address is :0x7fff5fbff908
Program ended with exit code: -1

MRC运行结果:
10 address is :0x7fff5fbff908
11 address is :0x7fff5fbff908
11 address is :0x7fff5fbff908
11 address is :0x7fff5fbff908
Program ended with exit code: -1

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马