In my Parse cloud code, I have custom errors like this
response.error({
"Error" : "DEAL EXPIRED",
"Title" : "Sorry!",
"Message" : "This deal is expired :(",
"Action" : "Ok"
});
Because I want to show a UIAlertView, but I have a problem to read the dictionary. My code in app is:
NSDictionary *errorDictionary = [error userInfo];
if ([[errorDictionary objectForKey:@"Error"] isEqualToString:@"DEAL EXPIRED"]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:
[NSString stringWithFormat:@"%@",[errorDictionary objectForKey:@"Title"]]
message:[NSString stringWithFormat:@"%@",[errorDictionary objectForKey:@"Message"]]
delegate:nil
cancelButtonTitle:[NSString stringWithFormat:@"%@",[errorDictionary objectForKey:@"Action"]]
otherButtonTitles:nil];
[alert show];
}
The log of errorDictionary is:
{"Error":"DEAL EXPIRED","Title":"Sorry!","Message":"This deal is expired :(","Action":"Ok"}
Thank you