Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Weather App with Swift Simple Data Structures Loading Files From A Directory

Wameedh Mohammed Ali
Wameedh Mohammed Ali
5,150 Points

Bummer! 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

plist.swift
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]{


}

Having the same issue (minus the third line)...

2 Answers

Write 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) {

    }
}