1
任何人都可以幫助,我有一些代碼,我正在檢查retainCount,但它總是-1,至少應該是1?retainCount總是-1?
這是我的代碼,我做錯了什麼?
NSNumber* n = [[NSNumber alloc] initWithInt:100];
NSLog(@"Count of n : %i",[n retainCount]);
NSNumber* n1 = n;
NSLog(@"Count of n : %i",[n retainCount]);
NSLog(@"Count of n1: %i",[n1 retainCount]);
NSLog(@"Address of n : %p", n);
NSLog(@"Address of n1: %p", n1);
的其他奇怪的事情,我得到的是關於%我,說這實際上是返回一個uint,所以我更換了%我到%u和現在我得到了retainCount一個很長的身影 - 4294967295
有點困惑,有什麼想法?
在此先感謝
有關使用'retainCount'的一些有用建議,請參閱http://whentouseretaincount.com。不要忘記向下滾動:) – mttrb
謝謝,很棒的信息 – Martin