Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Thomas Nilsen
14,957 PointsShowing Photos in a Collection View
I'm coding while watching the videos. But now I'm stuck. I receive an error sam doesn't get. After debugging it's complaining about the NSURL-line
- (void)setPhoto:(NSDictionary *)photo
{
_photo = photo;
NSURL *url = [NSURL URLWithString:_photo[@"images"][@"standard_resolution"][@"url"]];
[self downloadPhotoWithURL:url];
}
The error i get is:
2014-03-25 22:57:23.687 Photo Bombers[35537:60b] -[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8f4b2a0
2014-03-25 22:57:23.689 Photo Bombers[35537:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8f4b2a0'
Has anyone else experienced this?
2 Answers
Thomas Nilsen
14,957 PointsOk I figured it out. In the PhotosViewController when we download and parsed the JSON. In the video he writes:
self.photos = [responseDictionary valueForKeyPath:@"data.images.standard_resolution.url"];
When I downloaded the project to compare, it's just:
self.photos = [responseDictionary valueForKeyPath:@"data"];
Thomas Nilsen
14,957 PointsI found a temporary fix. If you override the setter as a NSString instead. But sam chose NSDictionary for a reason (to get more data than just the image links for later), so It's kind of annoying to not get that working. Any suggestion Amit Bijlani ? :)
Amit Bijlani
Treehouse Guest TeacherHave you tried logging the result for _photo[@"images"][@"standard_resolution"][@"url"] ? Are you passing the dictionary correctly?