cari

Rumah  >  Soal Jawab  >  teks badan

objective-c - ARC下,__weak 是否会改变对象的引用计数

ARC环境下,事例代码如下

    id __strong obj0 = [[NSObject alloc] init];
    id __weak obj = obj0;
    NSLog(@"obj0 :%p --- %ld", obj0, CFGetRetainCount((__bridge CFTypeRef) obj0));
    NSLog(@"obj  :%p --- %ld", obj, CFGetRetainCount((__bridge CFTypeRef) obj));

打印结果如下
2015-11-29 22:19:14.753 Test[15256:150713] obj0 :0x7f9f92d15d00 --- 1
2015-11-29 22:19:14.753 Test[15256:150713] obj :0x7f9f92d15d00 --- 3

这个3是怎么来的呢?

天蓬老师天蓬老师2764 hari yang lalu533

membalas semua(0)saya akan balas

Tiada jawapan
  • Batalbalas