Why is the retainCount still 1 after [object release]?

后端 未结 5 1268
Happy的楠姐
Happy的楠姐 2021-01-19 07:13
NSLog(@\"first:%u\",[object retainCount]);
[object release];
NSLog(@\"second:%u\",[object retainCount]);

Output:

first:1
second:1
5条回答
  •  走了就别回头了
    2021-01-19 07:31

    I agree with the other comments about not using retainCount to get a reliable count.

    EDIT: Ignore my stupidity below... :)

    However, I've observed that setting the corresponding property to nil...

    self.object = nil;
    

    the retainCount does tend to be decremented immediately.

提交回复
热议问题