[Solved] how to get server response and if server response is “Success” after show alert by JSON using objective c [closed]


Try This
Don’t need to use JSON simply try this code to get response from server

NSString *string= [[NSString alloc]initWithFormat:@"url"];
        NSLog(@"%@",string);
        NSURL *url = [NSURL URLWithString:string];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
        [request setHTTPMethod:@"POST"];

        NSURLResponse *response;
        NSError *err;
        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
        NSLog(@"responseData: %@", responseData);
        NSString *str = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
        NSLog(@"responseData: %@", str);
        NSString *str1 = @"1";
        if ([str isEqualToString:str1 ])
        {

            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Successfully" message:@"" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Try Again" message:@"" delegate:self cancelButtonTitle:@"Try Later" otherButtonTitles:@"Call", nil];
            alert.tag = 1;
            [alert show];
        }

if your response string is success than put this in the place of @"1"

11

solved how to get server response and if server response is “Success” after show alert by JSON using objective c [closed]