它应该返回 76 条记录的数组,但它返回了我<>谁能帮帮我吗 ? Web 服务已准备就绪,我需要获取数组响应并将其显示在我的表格视图中,请帮助我执行此操作
有几点想法:
You NSLog your webData,这将始终显示<>(因为您在实例化后立即记录它)。我不确定你为什么要记录它。
问题是你是否看到了<>, 或者NSLog in connectionDidFinishLoading.
我这么问是因为你没有记录error in connection:didFailWithError:,如果失败了,你永远不知道为什么。你真的应该记录error in connection:didFailWithError:这样你就知道它是否失败了,如果失败了,为什么:
NSLog(@"%s: %@", __FUNCTION__, error);
In your connection:didReceiveResponse:,你真的应该看看HTTP 状态码 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html:
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (statusCode != 200)
NSLog(@"%s: status code is %d; should be 200", __FUNCTION__, statusCode);
}
哪里,根据W3C 规范 http://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm for application/x-www-form-urlencoded,您不仅可以百分比转义,还可以将空格替换为+字符,因此: