@selector(apiRequest:didFinishWithData:) 不会执行,即使 fetcher 确实完成了数据。我试图用断点调试问题。当我循环通过断点时,我从选择器调用的方法没有被执行和绕过。这是因为选择器不在主线程上运行吗?我该如何纠正?
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(apiRequest:didFinishWithData:)
didFailSelector:@selector(apiRequest:didFailWithError:)];
(void)apiRequest:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(responseBody);
//could use this to implement errors
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:data //1
options:kNilOptions
error:&error];}
}