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 trialWameedh Mohammed Ali
5,150 PointsBummer! Don't forget to instantiate the dictionary with the contents of the plist!.
What am I doing wrong here? I am actually confused about this code! I just followed the lesson, even though I didn't get what is exactly the NSBundle and NSDictionary!
Thank you Wameedh
import Foundation
// Add your code below
if let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist"),
let crazyInfoDictionary = NSDictionary(contentsOfFile: plistPath),
let currentcrazyInfoDictionary = crazyInfoDictionary["Currentlly"] as? [String: AnyObject]{
}
2 Answers
Vitor Oliveira
6,766 PointsWrite two if let statements and it will work.
import Foundation
if let plistPath = NSBundle.mainBundle().pathForResource("crazyInformation", ofType: "plist") {
if let crazyInformationDictionary = NSDictionary(contentsOfFile: plistPath) {
}
}
Wameedh Mohammed Ali
5,150 PointsThank you!
Nicholas Westmoreland
5,937 PointsPhew, thanks
Max Roberts
2,502 PointsMax Roberts
2,502 PointsHaving the same issue (minus the third line)...