Those objects NSErrorthat the API gives you? Their goal is to tell you what went wrong. Use them.
, , , JSON. :
( , , ), , , , . , , .
. , , :
[post performRequestWithHandler:^(NSData *response, NSHTTPURLResponse *urlResponse, NSError *error) {
if (response) {
NSError *jsonError;
NSArray *array =[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&jsonError];
if (array) {
if ([array isKindOfClass:[NSArray class]]) {
self.array = array;
NSLog(@"resulted array: %@",self.array);
}
else {
NSLog(@"Not an array! %@ - %@", NSStringFromClass([array class]), array);
}
}
else {
NSLog(@"JSON Error %@", jsonError);
NSString *dataString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog(@"Received data: %@", dataString ? dataString : response);
}
}
else {
NSLog(@"request failed %@", error);
}
}];