开发者

Uialertview and memory management

开发者 https://www.devze.com 2023-01-28 08:35 出处:网络
If I alloc unit a UIAlertview and then s开发者_如何学Pythonhow it. Should I release it after the show or should I autorelease it?This is the common way of showing an alert:

If I alloc unit a UIAlertview and then s开发者_如何学Pythonhow it. Should I release it after the show or should I autorelease it?


This is the common way of showing an alert:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Title:" 
                                                message: @"The Message"
                                               delegate: self
                                      cancelButtonTitle: @"OK"
                                      otherButtonTitles: nil];
[alert show];
[alert release];


Release it after the show. It will retain itself until no longer needed.


It is good programming style to release it manually. Autorelease will also do the same thing but at it's own time. So it might release it latter also.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号