Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在xcode 4.5中使用Json进行storesearch_Objective C_Xcode4.5 - Fatal编程技术网

Objective c 在xcode 4.5中使用Json进行storesearch

Objective c 在xcode 4.5中使用Json进行storesearch,objective-c,xcode4.5,Objective C,Xcode4.5,我是新来的xcode。我不明白为什么在Xcode中没有错误,但是当我运行它时,模拟器一直在加载,我一直在努力解决我的错误。对不起,如果我英语不好。我认为解析数据时出现了问题,但我不知道如何修复它 - (void)performSearch { if ([self.searchBar.text length] > 0) { [self.searchBar resignFirstResponder]; [queue cancelAllOperatio

我是新来的
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}
-(无效)性能搜索
{
如果([self.searchBar.text length]>0){
[self.searchBar辞职FirstResponder];
[队列取消所有操作];
[[AFImageCache sharedImageCache]removeAllObjects];
[[NSURLCache sharedURLCache]移除所有缓存响应];
isLoading=是;
[self.tableView重载数据];
searchResults=[NSMutableArray阵列容量:10];
NSURL*url=[self-urlWithSearchText:self.searchBar.text类别:self.segmentedControl.selectedSegmentIndex];
NSURLRequest*request=[nsurlRequestRequestWithURL:url];
NSLog(@“请求:%@”,请求);
AFJSONRequestOperation*操作=[AFJSONRequestOperation
JSONRequestOperationWithRequest:request
成功:^(NSURLRequest*请求,NSHTTPURLResponse*响应,id JSON){
NSLog(@“成功!”);
}失败:^(NSURLRequest*请求,NSHTTPURLResponse*响应,NSError*错误,id JSON){
NSLog(@“故障!%@”,错误);
}];
[操作启动];
[操作等待完成];
// ???
[队列添加操作:操作];
}
}
2012-11-23 11:30:12.429 StoreSearch[5803:c07]请求:
2012-11-23 11:30:14.202 StoreSearch[5803:c07]***WebKit在webView中丢弃了一个未捕获的异常:shouldInsertText:replacingDOMRange:GivinaAction:delegate:**-[NSOperationQueue addOperation:]:操作已完成,无法排队
2012-11-23 11:30:14.211 StoreSearch[5803:c07]失败!错误域=com.alamofire.networking.Error Code=-1016“预期的内容类型{(
“text/json”,
“应用程序/json”
)},获取text/javascript“UserInfo=0xdf348b0{nserrorfailingurkey=http://itunes.apple.com/search?term=tr&limit=200&entity=,NSLocalizedDescription=预期的内容类型{(
“text/json”,
“应用程序/json”
)},获取text/javascript}

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