Use an action table, for example:
-(void)showDialog { loadingActionSheet = [[UIActionSheet alloc] initWithTitle:@"Something was saved!" delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; [loadingActionSheet showInView:self.view]; [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(closeActionSheet:) userInfo:nil repeats:NO]; } -(void)closeActionSheet:(id)sender { [loadingActionSheet dismissWithClickedButtonIndex:0 animated:YES]; }
Define UIActionSheet *loadingActionSheet; in your header and use @property and @synthesize .
You will also need to implement the UIActionSheetDelegate in your header.
source share