开发者

iOS4 (UIAlertView) why this code causes memory leaks?

开发者 https://www.devze.com 2023-01-27 15:44 出处:网络
suppose you create a new iOS app from scratch, with just one single window. then you put this code in the appD开发者_运维问答elegate application didFinishLaunching method :

suppose you create a new iOS app from scratch, with just one single window. then you put this code in the appD开发者_运维问答elegate application didFinishLaunching method :

UIAlertView *myAlert = [[UIAlertView alloc] 
  initWithTitle:@"alert"                                   
  message:@"message"
  delegate:nil /* same problem with 'delegate:self' */
  cancelButtonTitle:nil 
  otherButtonTitles:@"Ok", nil];
[myAlert show];
[myAlert release];

build and run in simulator 4.1, attach instrument, and... this causes each time a memory leak. in simulator 3.1.2 on leopard, no problem at all.

Of course, in a real app, the UIalertView is trigerred by a button, but the result is identical.

What is the problem ? is UIAlertView buggy until iOS4 ?


Don't check for leaks in a simulator. It doesn't have the same memory model so reports leaks when there aren't any.

Test on a real device and if the leak is still there, report it as a bug to Apple :)

0

精彩评论

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