The conclusion of various articles and questions and answers on the internet is that "the reference count value of the object cannot be printed under arc".
Indeed, ARC prohibits direct viewing of reference counts for Objective-c objects, but can objective-c objects be converted to core Foundation objects? So I did a little experiment:
id obj = [[NSObject alloc]init];printf("retain count = %ld\n",CFGetRetainCount((__bridge CFTypeRef)(obj)));
It is important to note that the __bridge is used here to convert, if it is converted with __bridge_retained, in fact, a core foundation object is generated, and the original Objective-c object is retain. Cause the reference count to be higher than the real value.
Run results
Retain count = 1
The project turns on Arc mode and correctly outputs the reference count value of the OC object.
View the reference count of an object under Arc