这里是我的代码: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