我需要在兩個搜索引擎中實現同步搜索。我有兩個功能: * - (空)searchYoutube:(NSString的)文本和 * - (空)searchYahoo:(NSString的)文本NSURLConnection的問題sendSynchronousRequest
(void) searchYahoo:(NSString *)text{
NSString *urlString = [NSString stringWithFormat:@"http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=%@&output=json&query=%@&results=30", YahooAppId, text];
NSLog(@"URL zaprosa: %@",urlString);
//Create NSURL string from formatted string
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSURLConnection *connection = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
if (connection)
{
NSLog(@"Data will be received from URL: %@", url);
}
else
{
NSLog(@"Data couldn't be received from URL: %@", url);
}}
功能-searchYoutube:是與上面類似。但是,當我用這兩個函數調用查詢時,我看到
2011-06-26 14:06:27.523 TrueSearcher[5373:207] URL query: http://gdata.youtube.com/feeds/api/videos?q=os&start-index=1&max-results=30&alt=jsonc&v=2
2011-06-26 14:06:27.874 TrueSearcher[5373:207] Data will be received from URL: http://gdata.youtube.com/feeds/api/videos?q=os&start-index=1&max-results=30&alt=jsonc&v=2
2011-06-26 14:06:27.875 TrueSearcher[5373:207] URL query: http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=jwGJkT32&output=json&query=os&results=30
2011-06-26 14:06:29.010 TrueSearcher[5373:207] Data will be received from URL: http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=jwGJkT32&output=json&query=os&results=30
而就是這樣。我無法收到任何數據。我究竟做錯了什麼?