Reputation: 548
Below is a dictionary I have created by retrieving the my twitter statuses for an App Only twitter feed. I have parsed and returned the value of "text" successfully, and displayed it in a table view cell as follows:
static NSString *cellID = @"FeedCell3" ;
FeedCell3 *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[FeedCell3 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
NSInteger idx = indexPath.row;
NSDictionary *t = self.twitterDataSource[idx];
cell.updateLabel.text = t[@"text"];
return cell;
However, when I try to return other values for keys such as "profile_image_url" and "screen_name" using the method below, an (null) is returned, even though there is a value in the dictionary. What am I doing wrong?
cell.nameLabel.text = t[@"screen_name"];
NSURL *profileImageURL = t[@"profile_image_url"];
NSLog(@"%@", profileImageURL);
Dictionary Data:
contributors = "<null>";
coordinates = "<null>";
"created_at" = "Thu May 01 20:15:32 +0000 2014";
entities = {
hashtags = (
);
symbols = (
);
urls = (
);
"user_mentions" = (
);
};
"favorite_count" = 0;
favorited = 0;
geo = "<null>";
id = 461962182734217473;
"id_str" = 46398745473;
"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>";
lang = fr;
place = "<null>";
"retweet_count" = 0;
retweeted = 0;
source = web;
text = "Test Tweet";
truncated = 0;
user = {
"contributors_enabled" = 0;
"created_at" = "Sun Mar 23 21:18:10 +0000 2014";
"default_profile" = 1;
"default_profile_image" = 1;
description = "";
entities = {
description = {
urls = (
);
};
};
"favourites_count" = 0;
"follow_request_sent" = "<null>";
"followers_count" = 1;
following = "<null>";
"friends_count" = 6;
"geo_enabled" = 0;
id = 24072342084;
"id_str" = 242344084;
"is_translation_enabled" = 0;
"is_translator" = 0;
lang = en;
"listed_count" = 0;
location = "";
name = "My Name";
notifications = "<null>";
"profile_background_color" = C0DEED;
"profile_background_image_url" = "http://abs.twimg.com/images/themes/theme1/bg.png";
"profile_background_image_url_https" = "https://abs.twimg.com/images/themes/theme1/bg.png";
"profile_background_tile" = 0;
"profile_image_url" = "http://abs.twimg.com/sticky/default_profile_images/default_profile_1_normal.png";
"profile_image_url_https" = "https://abs.twimg.com/sticky/default_profile_images/default_profile_1_normal.png";
"profile_link_color" = 0084B4;
"profile_sidebar_border_color" = C0DEED;
"profile_sidebar_fill_color" = DDEEF6;
"profile_text_color" = 333333;
"profile_use_background_image" = 1;
protected = 0;
"screen_name" = ScreenName;
"statuses_count" = 2;
"time_zone" = "<null>";
url = "<null>";
"utc_offset" = "<null>";
verified = 0;
};
Upvotes: 1
Views: 48
Reputation: 62676
Those latter two keys you're going for are in the user dictionary, so try
t[@"user"][@"screen_name"];
t[@"user"][@"profile_image_url"];
The second issue will appear when you solve the first. The url is a string. To get a proper NSURL you'll need to use an NSURL class method.
NSURL *aURL = [NSURL URLWithString:t[@"user"][@"profile_image_url"]];
Upvotes: 1