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

后端 未结 5 1301
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:23

    a Quote from NSObject reference on retainCount method

    This method is typically of no value in debugging memory management issues. Because any number of framework objects may have retained an object in order to hold references to it, while at the same time autorelease pools may be holding any number of deferred releases on an object, it is very unlikely that you can get useful information from this method.

提交回复
热议问题