我試圖按照使用SBJsonParser獲取Twitter提要,並將它們顯示在表視圖中的教程。[__NSCFDictionary isEqualToString:]:無法識別的選擇器發送到實例0x6b7e510'
但我收到以下錯誤
[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x6b7e510
這是什麼在我的
@interface
NSString *json_string; NSArray *statusArray;
這是代碼即時通訊使用來獲取Twitter的飼料
`SBJsonParser *parser = [[SBJsonParser alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://twitter.com/statuses/public_timeline.json"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
statusArray = [parser objectWithString:json_string error:nil];`
而這正是利用將其放到一個表視圖IM
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return statusArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.textLabel.text = [[statusArray objectAtIndex:indexPath.row] objectForKey:@"user"];
return cell;
}
編輯:
我NSLogged statusArray與objectatindex:0和我有
{
contributors = "<null>";
coordinates = "<null>";
"created_at" = "Mon Mar 26 19:43:54 +0000 2012";
favorited = 0;
geo = "<null>";
id = 184365079062528000;
"id_str" = 184365079062528000;
"in_reply_to_screen_name" = "<null>";
"in_reply_to_status_id" = "<null>";
"in_reply_to_status_id_str" = "<null>";
"in_reply_to_user_id" = "<null>";
"in_reply_to_user_id_str" = "<null>";
place = "<null>";
"retweet_count" = 0;
retweeted = 0;
source = "<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\U00ae</a>";
text = "Kalau tidur jam segini engga mungkin bisa mimpi-___-";
truncated = 0;
user = {
"contributors_enabled" = 0;
"created_at" = "Tue Apr 27 18:28:24 +0000 2010";
"default_profile" = 0;
"default_profile_image" = 0;
description = "27June!";
"favourites_count" = 0;
"follow_request_sent" = "<null>";
"followers_count" = 733;
following = "<null>";
"friends_count" = 331;
"geo_enabled" = 1;
id = 137772903;
"id_str" = 137772903;
"is_translator" = 0;
lang = en;
"listed_count" = 0;
location = "";
name = "Faisal Maulana \U2606";
notifications = "<null>";
"profile_background_color" = 050505;
"profile_background_image_url" = "http://a0.twimg.com/profile_background_images/451260814/428031_258048570950875_100002372012794_560610_1320195241_n.jpg";
"profile_background_image_url_https" = "https://si0.twimg.com/profile_background_images/451260814/428031_258048570950875_100002372012794_560610_1320195241_n.jpg";
"profile_background_tile" = 1;
"profile_image_url" = "http://a0.twimg.com/profile_images/1962687246/IMG01822-20120319-1126_normal.jpg";
"profile_image_url_https" = "https://si0.twimg.com/profile_images/1962687246/IMG01822-20120319-1126_normal.jpg";
"profile_link_color" = 0a0a0a;
"profile_sidebar_border_color" = 161717;
"profile_sidebar_fill_color" = ffffff;
"profile_text_color" = 050505;
"profile_use_background_image" = 1;
protected = 0;
"screen_name" = IcalHuba;
"show_all_inline_media" = 0;
"statuses_count" = 60850;
"time_zone" = Greenland;
url = "<null>";
"utc_offset" = "-10800";
verified = 0;
};
}
因爲JSON解析器返回一個自動釋放對象,所以你的statusArray在作用域結束時被取消分配。 - 保留它。 – 2012-03-26 19:28:53
但ARC禁止保留? – Huntaz556 2012-03-26 19:33:28
你確定你正在得到statusArray或它的零嗎?你能告訴我們statusArray的價值嗎? – 2012-03-26 19:45:13