這裏是我的代碼:iPhone內存管理問題和對象的LiveCycle
電話SDK undestanding可可對象使用生命週期:
- (void) DismissWelcomeMessage: (UIAlertView *) view
{
[view dismissWithClickedButtonIndex:0 animated:YES];
}
- (void) ShowWelcomeMessage
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Blah" message:@"Blah Blah" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[self performSelector:@selector (DismissWelcomeMessage:) withObject: alert afterDelay: WELCOME_MESSAGE_DELAY];
[alert release];
}
ShowWelcomeMessage首先調用。
爲什麼DissmissWelcomeMessage工作正常,即使發佈警報對象也不會崩潰?
是因爲Dismiss函數使用堆棧上傳遞的對象的副本作爲函數時的參數嗎?但即使如此,它不會只是指向現在釋放的對象的指針的副本?
或[警報發佈]只是引用計數,並沒有真正做到 在C++中刪除?
謝謝,我錯過了NSObject文檔中的那部分內容! – leon 2009-10-04 03:49:38