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 trialOwen Hughes
10,188 PointsQuestion not accepting correct answer
So, I'm trying to safely instantiate a dictionary from a plist as per the question, but it's not accepting my answer. I've also tried just using bangs to force unwrap like this:
```if let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist")! let crazyDict = NSDictionary(contentsOfFile: plistPath)!
I've used the code just fine in an xcode project - am I missing something here?
```plist.swift
import Foundation
// Add your code below
if let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist"),
let crazyDict = NSDictionary(contentsOfFile: plistPath) {
}
2 Answers
Owen Hughes
10,188 PointsGot it
if let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist") {
let crazyDictionary = NSDictionary(contentsOfFile: plistPath)
}
Very ambiguously phrased question. Especially considering in the previous video, a similar problem was solved differently.
Ernie Ayon
3,441 PointsThanks! Yeah, I was a little confused as to why it wouldn't work. Missing the if and {}
Matthew Davies
14,579 PointsUnfortunately there are many ways to solve this and they wanted to see a specific way. The question needs to be more specific. Anyways your response helped me get past this code challenge so, thank you good sir!
Owen Hughes
10,188 PointsOwen Hughes
10,188 PointsTo add context, this is the first code challenge in the "Build a weather app with Swift" course. I thought the question would be included in this post automatically.