API を介してデータベースと通信する iOS アプリケーションを作成しています。API は有効な JSON をアプリケーションに送信しますが、アプリケーションはエラーを返さず、別の結果 NULL を返します。
iOS アプリのコードは次のとおりです。
// Start hud
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Zoeken...";
return TRUE;
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (request.responseStatusCode == 400) {
textView.text = @"Invalid code";
} else if (request.responseStatusCode == 403) {
textView.text = @"Code already used";
} else if (request.responseStatusCode == 204) {
textView.text = @"No content";
} else if (request.responseStatusCode == 412) {
textView.text = @"Precondition Failed";
} else if (request.responseStatusCode == 200) {
NSString *responseString = [request responseString];
NSDictionary *responseDict = [responseString JSONValue];
// NSString *naam = [responseDict objectForKey:@"DEB_NR"];
NSString *part0 = [responseDict objectForKey:@"klntnr"];
NSString *part1 = [responseDict objectForKey:@"klntnm"];
NSString *part2 = [responseDict objectForKey:@"adrs"];
NSString *show = [NSString stringWithFormat:@"\r%@\r%@\r%@" , part0 , part1 , part2 ];
// if ([unlockCode compare:@"com.razeware.test.unlock.cake"] == NSOrderedSame) {
textView.text = [NSString stringWithFormat:@"Resultaten: %@", show];
// } else {
// textView.text = [NSString stringWithFormat:@"Resultaat: %@", unlockCode];
// }
} else {
textView.text = @"Unexpected error API ERROR";
}
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSError *error = [request error];
textView.text = error.localizedDescription;
}
@end
前もって感謝します、
モーリス。