関連データを受け取るために、ネストされた辞書を使用して、POST メソッドで Web サービスにアクセスする必要があります。しかし、私は空の応答を続けています。私は何を間違っていますか?
NSURL *url = [NSURL URLWithString:@"http://appzander.com/gateway.php"];
ASIFormDataRequest *_request = [ASIFormDataRequest requestWithURL:url];
__weak ASIFormDataRequest *request = _request;
AppDelegate *app = [[UIApplication sharedApplication] delegate];
NSDictionary *paramsDic = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithDouble:app.myLocation.longitude],@"longitude",
[NSNumber numberWithDouble:app.myLocation.latitude],@"latitude",
@"500000",@"radius",
@"1000",@"maxResults",
nil];
NSDictionary *requestDic = [[NSDictionary alloc] initWithObjectsAndKeys:
@"GetNearestStations",@"function",
@"false",@"debug",
paramsDic,@"params",
nil];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request appendPostData:[[SBJsonWriter new] dataWithObject:requestDic]];
request.requestMethod = @"POST";
[request setDelegate:self];
[request setCompletionBlock:^{
NSData *responseString = [request responseData];// responseString];
NSLog(@"Response: %@", responseString);
[self plotCrimePositions:responseString];
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"Error: %@", error.localizedDescription);
}];
// 6
[request startAsynchronous];