crash - UIActionSheet crashes after appearing again on iPad -
the uiactionsheet crashes after appears second time through..
.h file
..uiactionsheetdelegate>{ uiactionsheet *popupquery; } @property (nonatomic, retain) uiactionsheet *popupquery; .m file
-(ibaction)showactionsheet:(id)sender { if (popupquery.visible) { nslog(@"popupquery isvisible"); [popupquery dismisswithclickedbuttonindex:-1 animated:yes]; return; }else{ popupquery = [[uiactionsheet alloc] initwithtitle:@"title" delegate:self cancelbuttontitle:@"cancel" destructivebuttontitle:@"readibility" otherbuttontitles:@"email url", @"print", nil]; popupquery.actionsheetstyle = uiactionsheetstyleblackopaque; //[popupquery showinview:self.view]; [popupquery showfrombarbuttonitem:actionbutton animated:yes]; [popupquery release]; } }
when release popupquery after showing actionbutton, relinquish ownership on object. if object gets deallocated popupquery point deallocated object when popupquery.visible might give crash. since have property, can –
self.popupquery = [[[uiactionsheet alloc] initwithtitle:@"title" delegate:self cancelbuttontitle:@"cancel" destructivebuttontitle:@"readibility" otherbuttontitles:@"email url", @"print", nil] autorelease]; remove release statement @ end. object valid when popupquery.visible or self.poupquery.visible in case, have ownership , can safely access object.
Comments
Post a Comment