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
tat
447 Pointsobject for key
Whats the difference between these two lines of code ?
self.textView.text = self.importVideoMetaData[@"description"];
self.textView.text = [self.importVideoMetaData objectForKey:@"description"];
2 Answers
Christina Cherry
1,110 PointsI'm no expert but I think the objectForKey means it's an object that is identified by an array or in a plist. For example:
I have a plist that has as its root an Array, each item is a dictionary with strings in it, those strings are referred to in my code to call up as keys as follows
<array> <---- root of the list <dict> <----- holds the keys <key>name</key> <string>Christina</string> <key>description</key> <string>Awesome</string> </dict> </array>
So in your second row of code you would be importing video meta data based on the description rather than the name
Does that help?
So in your case you would have another row as follows
Amit Bijlani
Treehouse Guest Teacher@tauseef the latest version of Xcode supports new Objective-C syntax called literals. Just as you use @"some string" to create a string object which is known as a string literal. Now you can use literals with other classes such as NSNumber, NSArray,NSDictionary and a few others. In the above example, both lines of code are equivalent. If you want detailed information on literals then check out: http://clang.llvm.org/docs/ObjectiveCLiterals.html