iPhone - how can this code leak? -
very simple code, leaks hell... check out.
- (void)loadview { nsstring * mytitle = @"hello"; nsstring * message = @"\nthis stuff leaking!\n"; nsstring * cancelbutton = @"dismiss"; nsstring * othertitles = nil; [self showalert: mytitle : message: cancelbutton : othertitles]; } - (void) showalert: (nsstring *) titulo : (nsstring *) mensagem : (nsstring *) cancelbutton : (nsstring *) otherbutton { uialertview * alertview = nil; if (otherbutton) { alertview = [[uialertview alloc] initwithtitle:titulo message:mensagem delegate:self cancelbuttontitle:cancelbutton otherbuttontitles:otherbutton, nil ]; } else { alertview = [[uialertview alloc] initwithtitle:titulo message:mensagem delegate:self cancelbuttontitle:cancelbutton otherbuttontitles:nil ]; } [alertview show]; [alertview release]; }
here project, if wanna try on instruments... http://www.mediafire.com/download.php?hml2hl5laz9ez2j
how solve that?
thanks.
i tried run myself in instruments, , not these leaks. there must wrong other parts of code, seems fine me.
only thing i'll pick on way run showalert:
, [self showalert: mytitle : message: cancelbutton : othertitles];
. think quite ugly, should change function
- (void) showalertwithtitle:(nsstring *)title message:(nsstring *)message cancelbutton:(nsstring *)cancelbutton otherbutton:(nsstring *)otherbutton
and run [self showalertwithtitle:title message:message cancelbutton:cancelbutton otherbutton:otherbutton];
.
Comments
Post a Comment