0
我試圖將Rotten Tomatoes API添加到我的應用,但它似乎並不喜歡它?我究竟做錯了什麼??錯誤說「不使用的格式字符串的數據論證」將爛Tomates API添加到iphone應用
-(void)main {
NSLog(@"Service has run");
NSString *api_key = @"j4jz49tvf76cmnb4mwfyjvyt";
NSString *search_term = [searchTerm stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString *url = [NSString stringWithFormat:@"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?limit=16&country=us&apikey=j4jz49tvf76cmnb4mwfyjvyt", api_key, search_term];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
if (responseData !=nil) {
NSError *error =nil;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions error:&error];
if (error) {
[delegate serviceFinished:self withError:YES];
} else {
results = (NSArray *) [json valueForKey:@"movies"];
[delegate serviceFinished:self withError:NO];
}
} else {
[delegate serviceFinished:self withError:YES];
}
}
@end
唉唉,感謝您的幫助,我的大學都提供的教程指導我寫它,我怎麼原本它。然而,即使在代碼更改之後,我的應用仍然不會從爛番茄中獲取電影列表。任何想法,爲什麼這是? –
我沒有製作正確的URL,我只是提供了一個例子,說明它可能應該如何格式化。假設您對編程有基本的瞭解,我建議閱讀http://developer.rottentomatoes.com/docs開發人員文檔。 –
我明白了。謝謝!! –