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

Aniket Kumar
Aniket Kumar
3,266 Points

Help with 'build a weather app' challenge task

The task says, "Don't forget to instantiate the dictionary with the plist!" I have no idea where I am going wrong.

plist.swift
import Foundation

// Add your code below


let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist"),
let informationDictionary = NSDictionary(contentsOfFile: plistPath)

1 Answer

Hi Aniket

Your first line ends with a comma, which will certainly not work :) However, if you meant to end it with a bang (!) to unwrap the returned path, then you are not wrong. But in doing so you risk a crash if pathForResource returns nil. If you implement an if-let statement, and only populate the dictionary if you actually get a valid path back from pathForResource, then you should be able to move on...

Need specifics? I prefer not to type out the solution.

Aniket Kumar
Aniket Kumar
3,266 Points

Thanks a lot Rasmus, I figured it out.