回答#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
爲您的處理程序,這是一個直觀的實現來看待的幫助編寫自己的。