我正在使用 MKNewtworkkit 进行网络操作是我的 ios 应用程序。我在服务器中有 JSONInterface,我可以通过它检索 JSONArray。我也能够在 android 应用程序和浏览器中获取数据,但是当我尝试使用 MKNetworkkit [completedOperation responseJSON] 获取 ftech 数据时返回 nil。请你帮助我好吗
MKNetworkEngine *network_engine= [[MKNetworkEngine alloc] initWithHostName:@"****.com"];
NSMutableDictionary* params=[[NSMutableDictionary alloc] initWithCapacity:3];
[params setObject:[self.userName text] forKey:@"user"];
[params setObject:[self.password text] forKey:@"password"];
[params setObject:@" " forKey:@"meters"];
MKNetworkOperation* operation =[network_engine operationWithPath:@"q/out" params:params httpMethod:@"GET" ssl:NO];
[operation onCompletion:^(MKNetworkOperation *completedOperation) {
NSLog(@"response: %@",[completedOperation responseString]);
@try {
NSArray *data_array=[completedOperation responseJSON];
for (int i=0; i<[data_array count]; i++) {
NSDictionary *dict=[data_array objectAtIndex:i];
NSString *id=[dict valueForKey:@"mid"];
NSString *location=[dict valueForKey:@"location"];
NSLog(@"id:%@ , location:%@",id,location);
}
}
@catch (NSException *exception) {
NSLog(@"Exception: %@",[exception name]);
}
} onError:^(NSError *error) {
NSLog(@"Couldn't make network call");
}];
[network_engine enqueueOperation:operation];