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 trialAlex Chiang
2,222 PointsWe added a NSString *thumbnail to property. Why can't we just set it as NSURL *thumbnail?
If we set the property as NSURL *thumbnail. then we don't have to create an extra method to convert NSString to USURL. Why didn't the instructor do that in the video?
1 Answer
Oliver Duncan
16,642 PointsThis is late, but I was wondering the same thing. I think it's because the property 'thumbnail' in the dictionary returned by parsing the JSON is an NSString, and I wouldn't imagine you can coerce a string into a URL object that easily - we have to let Objective-C do that for us behind the scenes. So, we instead initialize an instance of NSURL with it's convenience constructor method using the NSString that is returned by the JSON data.