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

Sebastian Nitu
Sebastian Nitu
8,616 Points

I am having a hard time understanding what is missing from the Code Challenge based on the request.

Hello everyone,

It seems that i might not fully understand what is asked of me from this exercise.

I have created the following lines in the exercise:

The plistPath:

let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", "plist")

...and I have created an instance of NSDictionary and passed plistPath to it:

let crazyDictionary = NSDictionary(contenstOfFile: plistPath)

Unfortunately I still can't seem to be able to get passed the challenge.

plist.swift
import Foundation

// Add your code below
let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", "plist")
let crazyDictionary = NSDictionary(contenstOfFile: plistPath)

1 Answer

You need to use optional binding syntax like this:

if let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist") {

  let dictionary = NSDictionary(contentsOfFile: plistPath)

  }

Also, you you misspelled "contents" in contentsOfFile and did't prefix "plist" with the keyword "ofType" in the first line.