Basically, I have this if statement:
NSString *loginResult = [resultsArray valueForKey:@"statusMsg"];
if ([loginResult isEqualToString:@"success"])
{
[self successDialog]; // Success
}
else
{
[self failedDialog]; // Failed
}
This is the parsed JSON if success:
{"results":{"statusMsg":"success"}}
If failed, parsed JSON varies:
{"results":{"statusMsg":"password incorrect."}}
I want to pass the string value returned by the key statusMsg to my alert view inside the failedDialog method. The failedDialog method is defined as:
- (void)failedDialog:(NSString *)errorMessage
{
UIAlertView *dialog = [[UIAlertView alloc] initWithTitle:kRegFailed
message:errorMessage
delegate:self
cancelButtonTitle:kOK
otherButtonTitles:nil, nil];
dialog.tag = 2;
[dialog show];
}
How can I do that so that the alert view will have the error message returned. TIA!
Wonder why you doing this if your resultsArray is NSArray object
Put this in your header file
Try this, suppose your jsonDict = { “results” :{ “statusMsg” : “password incorrect.” } }