2

我是新来的xcode。我不明白为什么没有错误,Xcode但是当我运行它时,模拟器一直在加载,并且我遇到了错误。对不起,如果我的英语不好。我认为解析数据时出了点问题,但我只是不知道如何修复它。

- (void)performSearch
{

    if ([self.searchBar.text length] > 0) {
        [self.searchBar resignFirstResponder];

        [queue cancelAllOperations];
        [[AFImageCache sharedImageCache] removeAllObjects];
        [[NSURLCache sharedURLCache] removeAllCachedResponses];

        isLoading = YES;
        [self.tableView reloadData];

        searchResults = [NSMutableArray arrayWithCapacity:10];

        NSURL *url = [self urlWithSearchText:self.searchBar.text category:self.segmentedControl.selectedSegmentIndex];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        NSLog(@"REQUEST: %@", request);

        AFJSONRequestOperation *operation = [AFJSONRequestOperation
                                             JSONRequestOperationWithRequest:request
                                             success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
                                                 NSLog(@"Success!");

                                             } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
                                                 NSLog(@"Failure! %@", error);
                                             }];
        [operation start];
        [operation waitUntilFinished];
                  // ???
        [queue addOperation:operation];
    }
}




2012-11-23 11:30:12.429 StoreSearch[5803:c07] REQUEST: <NSURLRequest http://itunes.apple.com/search?term=tr&limit=200&entity=>
2012-11-23 11:30:14.202 StoreSearch[5803:c07] *** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: <NSInvalidArgumentException> *** -[NSOperationQueue addOperation:]: operation is finished and cannot be enqueued
2012-11-23 11:30:14.211 StoreSearch[5803:c07] Failure! Error Domain=com.alamofire.networking.error Code=-1016 "Expected content type {(
    "text/json",
    "application/json"
)}, got text/javascript" UserInfo=0xdf348b0 {NSErrorFailingURLKey=http://itunes.apple.com/search?term=tr&limit=200&entity=, NSLocalizedDescription=Expected content type {(
    "text/json",
    "application/json"
)}, got text/javascript}
4

1 回答 1

0

似乎您得到的响应不是 json。您能否尝试从终端卷曲请求 URL 并查看它给出的响应。

于 2012-11-23T07:35:11.067 回答