我最近才切换到 AFNetworking 来处理我的应用程序中的所有网络。但是,它现在似乎阻塞了主线程,因此我的 MBProgressHUD 直到操作完成后才会旋转,并且我的 pullToRefreshView 也不会在操作之后进行动画处理。我将如何解决这个问题?
- (void)pullToRefreshViewShouldRefresh:(PullToRefreshView *)view; {
// Call the refreshData method to update the table
[dataController refreshData];
}
- (void)refreshData {
NSURLRequest *request = [NSURLRequest requestWithURL:[FCDataController parserURL]];
NSLog(@"URL = %@", request);
AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
_calls = [[NSMutableArray alloc] init];
XMLParser.delegate = self;
[XMLParser parse];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser) {
if ([delegate respondsToSelector:@selector(refreshDataDidFailWithError:)]) {
[delegate refreshDataDidFailWithError:error];
}
}];
[operation start];
}