我正在尝试让AFJSONRequestOperation与http://www.crowdkind.org/mobile/offers一起使用。
我完成了同步部分并返回数据并将其放入表格中。当我将其转换为AFJSONRequestOperation时 - 我没有得到回复。 NSLog告诉我,该操作被发送。但我永远不会得到“操作成功或失败”。知道可能会发生什么吗?这是我的searchBarButtonClicked方法...
将URLtoSearch设置为... http://www.crowdkind.org/mobile/offers。 (随意点击,因为它是有效的JSON)。
- (void)searchBarSearchButtonClicked
{
searchResults = [NSMutableArray arrayWithCapacity:10];
[queue cancelAllOperations];
isLoading = YES;
[self.tableView reloadData];
NSURL *url = [self urlWithSearchText:URLtoSearch];
NSLog(@"URL: %@", URLtoSearch);
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"Operation succeeded");
[self parseDictionary:JSON];
[searchResults sortUsingSelector:@selector(compareName:)];
isLoading = NO;
[self.tableView reloadData];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Operation failed");
[self showNetworkError];
isLoading = NO;
[self.tableView reloadData];
}];
operation.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
[queue addOperation:operation];
NSLog(@"Operation added");
}
我没有回应。检查链接,它是有效的json。任何想法都非常感谢!