1

I have created request and I want to popView when i will get success message in response. Here is my code :

NSURLSession *session = [NSURLSession sharedSession];
NSString *baseURLRequest = [NSString stringWithFormat:@"%@/email_addr=%@",mySession.baseURL,self.txtEmail.text];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:[NSURL URLWithString:baseURLRequest] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
    NSDictionary *dict = [json objectForKey:@"result"];
    NSString *msg = [dict objectForKey:@"msg"];

        if ([[dict objectForKey:@"status"] isEqualToString:@"success"])
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self showMesssgeonAlert:@"Success"];
                [self hideProgress];

                [self.navigationController popViewControllerAnimated:YES];
            });
        }
        else
        {
        }
}];
[dataTask resume];

Below isn't working,

[self.navigationController popViewControllerAnimated:YES];

Does anyone have an idea why this is happening? UINavigation controller is also same for both the viewControllers. Please help me,Thanks.

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
DevTest
  • 11
  • 2

1 Answers1

-2

@DevTest you can not put [self.navigationController popViewControllerAnimated:YES]; inside dispath queue, queue will not pop viewcontroller so, you will set out side dispatch queue...

Akshay Degada
  • 139
  • 2
  • 13