0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
       UIAlertController *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                        message:@"Are you sure you want to Delete your account ?"
                                                       delegate:self
                                              cancelButtonTitle:@"Delete Account"
                                              otherButtonTitles:@"Cancel", nil];
        
        UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction * action) {
                                                       //Do Some action here
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"logged_in"];
//        alert.tag = 104;
//        [alert show];

        [self displayAlertForRemoveAccountWithMessage:@"Are you sure you want to Delete your account  ?"];
            
            UINavigationController *nav = [self.storyboard instantiateViewControllerWithIdentifier:@"stratingNav"];
        [nav setModalPresentationStyle: UIModalPresentationOverFullScreen];
            [self presentViewController:nav animated:YES completion:nil];
                                               }];
    UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction * action) {
                                                       [alert dismissViewControllerAnimated:YES completion:nil];

                                                   }];

    [alert addAction:ok];
    [alert addAction:cancel];


    [self presentViewController:alert animated:YES completion:nil];


    }

- (void)displayAlertForRemoveAccountWithMessage :(NSString *)message
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                    message:message
                                                   delegate:self
                                          cancelButtonTitle:@"Delete Account"
                                          otherButtonTitles:@"Cancel", nil];
    alert.tag = 103;
    [alert show];
}

i am trying to implement delete account function with objective c kindly please tell me what else need to be added in this code..

RajeshKumar R
  • 15,445
  • 2
  • 38
  • 70
  • Your code is mixinig `UIAlertView` & `UIAlertController`? Your coded is unclear. As I said no your previously deleteted question: What do you save regarding the user account info, and where? – Larme Oct 26 '22 at 10:38
  • I'm saving the username, email id and password and it is being saved on server – Chipmonk LLoyd Oct 26 '22 at 10:43
  • So, remove these infos locally, and I guess you should also make a HTTP request to remove them from server. See https://developer.apple.com/support/offering-account-deletion-in-your-app – Larme Oct 26 '22 at 10:45
  • for that i have added removeObjectForKey:@"logged_in" for removing login details – Chipmonk LLoyd Oct 26 '22 at 10:47
  • As said by @Larme , 'UIAlertController *alert = [[UIAlertView alloc ...]' make no sense and UIAlertView is deprecated. You must have some warning during build. – Ptit Xav Oct 27 '22 at 10:11

0 Answers0