Deprecate and remove -retainCount

Originator:davedelong
Number:rdar://8122368 Date Originated:23 Jun 2010
Status:Open Resolved:
Product:Other Product Version:Foundation.framework
Classification:Serious Bug Reproducible:Always
 
Summary:
The existence of the -retainCount method on <NSObject> is the source of endless confusion among developers new to the iPhone/iPad/Mac development environment, and usually leads to vomit-worthy code like:

while([anObject retainCount] > 0) { [anObject release]; }

The documentation itself says: 
"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."

Steps to Reproduce:
Click: http://www.google.com/search?q=site:stackoverflow.com+retainCount

Expected Results:
-retainCount should not exist

Actual Results:
-retainCount exists

Regression:
This has been a problem since before Mac OS X 10.0.

Notes:
The simple fix would be to simply remove the implementation of -retainCount.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!