に送ら:[NSCFString objectForKeyは:]:認識されていないセレクタがこのコードでインスタンス
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
//---initialize the array---
listOfJMovies = [[NSMutableArray alloc] init];
listOfJMoviePosters = [[NSMutableArray alloc] init];
tmdbMovies = [[NSArray alloc] init];
posters = [[NSArray alloc] init];
thumbs = [[NSArray alloc] init];
//---set the title---
self.navigationItem.title = @"Movies";
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//NSLog(responseString);
SBJsonParser *json = [[SBJsonParser new] autorelease];
tmdbMovies = [json objectWithString:responseString error:nil];
for (id movie in tmdbMovies) {
[listOfJMovies addObject:[movie objectForKey:@"name"]];
NSLog(@"Name: %@", [movie objectForKey:@"name"]);
//[listOfJMoviePosters addObject:[obj objectForKey:@"posters"]];
//NSLog(@"%@", [obj objectForKey:@"posters"]);
posters = [movie objectForKey:@"posters"];
for (id image in posters) {
NSLog(@"image: %@", [image objectForKey:@"image"]);
thumbs = [image objectForKey:@"image"];
for (id url in thumbs) {
NSLog(@"Size: %@", [url objectForKey:@"size"]);
//NSLog(@"blah");
//[listOfJMoviePosters addObject:[url objectForKey:@"size"]];
}
}
}
[[self tableView] reloadData];
[responseString release];
[connection release];
[responseData release];
}
この行:のNSLog(@ "サイズ:%@"、[URLのobjectForKey:@ "サイズ"])。
アプリは、次のエラーをクラッシュし、スローする原因となっている:
2010-12-30 00:33:29.730 FlixIt [33132:207] - [NSCFString objectForKey:]:認識されていないセレクタはインスタンスに0x4e50f00 を送信しました2010-12-30 00:33:29.732 FlixIt [33132:207] *がキャッチされない例外により 'NSInvalidArgumentException'、理由にアプリを終了: -
'[NSCFString objectForKeyは:]未認識セレクタインスタンス0x4e50f00に送ら'ここにJSONがあります:http://api.themoviedb.org/2.1/Movie.browse/en-US/json/e5084159b962a8f0c39096f379a1363c?order_by=rating&order=desc&genres=18&min_votes=5&page=1&per_page=10
ありがとうございます!それは動作します。しかし、次の警告が表示されます: 'NSArray'が '-objectForKey:'に応答しない可能性があります。 – user558096
NSArrayをNSDictionaryに変更しました。再度、感謝します! – user558096