回答 #2:您需要在发送请求之前为响应提供处理程序TTURLJSONResponse
,这不是实际的响应,但它负责处理响应。这是您处理字符串和 URL 数组的响应的地方。
它实际上是一个名为的协议TTURLResponse
,它定义了以下实现方法:
/**
* Processes the data from a successful request and determines if it is valid.
*
* If the data is not valid, return an error. The data will not be cached if there is an error.
*
* @param request The request this response is bound to.
* @param response The response object, useful for getting the status code.
* @param data The data received from the TTURLRequest.
* @return NSError if there was an error parsing the data. nil otherwise.
*
* @required
*/
- (NSError*)request:(TTURLRequest*)request
processResponse:(NSHTTPURLResponse*)response
data:(id)data;
您选择了TTURLJSONResponse
作为您的处理程序,这是一个直接的实现,可以帮助您编写自己的代码。