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

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

    }
}