【发布时间】:2025-12-04 07:30:01
【问题描述】:
我是 Objective C 的新手,我有一个 NSMutableArray,里面有 3 个对象,然后我尝试打印数组的 retainCount。为什么最终的 retainCount 返回 -1?谢谢
NSLog(@"myArray has retain count of %d", [myArray retainCount]);
[myArray release];
NSLog(@"myArray has retain count of %d", [myArray retainCount]);
控制台结果:
2010-10-17 11:58:06.407 TestRetainCount [527:a0f] myArray has retain count of 1
2010-10-17 11:58:06.407 TestRetainCount [527:a0f] myArray has retain count of -1
【问题讨论】: