我想呈現一個模態視圖控制器。我已閱讀文檔,但有些奇怪。這裏是我的代碼:Presentmodalviewcontroller方法問題與保留計數
NSLog(@"rc: %d", [modalViewController retainCount]);
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:modalViewController];
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
NSLog(@"rc: %d", [modalViewController retainCount]);
並在控制檯上出現:
RC:2
RC:24
而且我覺得24是很奇怪......你這是什麼瘦?這是爲什麼發生?
我不知道你的具體問題,但 - [NSObject retainCount]返回一個NSUInteger,所以你應該在格式字符串中使用%u,而不是%d。 – 2010-04-14 10:02:04
好的,我已改爲%u。一樣的。 – 2010-04-14 10:04:11