我正在尝试使用 SBJSON 框架为 iPhone 使用 JSON Feed。我最初确实尝试了一个示例,并且效果很好。但是当我使用我的 URL JSON 进行更改时,它找不到正确的密钥。我不确定我是否正确,因为我是学习 iPhone 的 JSON 框架的新手。下面是我的 JSON 提要:
[
{
"place": null,
"in_reply_to_user_id": null,
"user": {
"notifications": null,
"friends_count": 37,
"profile_text_color": "000000",
"protected": false,
"is_translator": false,
"profile_sidebar_fill_color": "f1f6f9",
"location": "St. Louis, MO",
"name": "Annual Meeting",
"follow_request_sent": null,
"profile_background_tile": true,
"show_all_inline_media": false,
"geo_enabled": false,
"utc_offset": -18000,
"url": "http://www.center.org/meet",
"id_str": "15336703",
"following": null,
"verified": false,
"favourites_count": 0,
"profile_link_color": "CB2828",
"description": "Annual Meeting Twitterstream -- Join us in St. Louis, MO!",
"default_profile": false,
"created_at": "Sun Jul 06 23:26:33 +0000 2008",
"profile_sidebar_border_color": "000000",
"listed_count": 105,
"statuses_count": 400,
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/20080706-rh1nqc98x97hyg133ji774pix1.jpg",
"time_zone": "Eastern Time (US & Canada)",
"profile_image_url": "http://a1.twimg.com/profile_images/AnnualMeeting2011_Twitter_Icon_normal.jpg",
"profile_use_background_image": false,
"profile_image_url_https": "https://si0.twimg.com/profile_images/1257786946/AnnualMeeting2011_Twitter_Icon_normal.jpg",
"id": 15336703,
"profile_background_color": "015196",
"followers_count": 2311,
"screen_name": "11",
"contributors_enabled": false,
"profile_background_image_url": "http://a3.twimg.com/profile_background_images/20080706-rh1nqc98x97hyg133ji774pix1.jpg",
"default_profile_image": false,
"lang": "en"
},
"in_reply_to_status_id": null,
"text": "Acronym blog is seeking guest bloggers at #11 http://bit.ly/nlDUOe",
"id_str": "91972636405530624",
"favorited": false,
"created_at": "Fri Jul 10 20:49:19 +0000 2011",
"in_reply_to_status_id_str": null,
"geo": null,
"in_reply_to_screen_name": null,
"id": 91972636405530620,
"in_reply_to_user_id_str": null,
"source": "<a href=\"http://cotweet.com/?utm_source=sp1\" rel=\"nofollow\">CoTweet</a>",
"contributors": null,
"coordinates": null,
"retweeted": false,
"retweet_count": 2,
"truncated": false
},
找出正确密钥的代码:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSDictionary *results = [responseString JSONFragmentValue];
NSArray *allTweets = [results objectForKey:@"user"]; // ** Error on this line, dont know what key is the correct one ? **///
[viewController setTweets:allTweets];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}