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 NSBundle and the File Directory

I'm getting errors while executing this code.

I executed the following code as shown in the tutorial:

 if let plistPath = NSBundle.mainBundle().pathForResource("CurrentWeather", ofType: "plist"),
        let weatherDictionary = NSDictionary(contentsOfFile: plistPath),
        let currentWeatherDicitonary = weatherDictionary["currently"] as? [String: AnyObject] {

            let currentWeather = CurrentWeather(weatherDictionary: currentWeatherDicitonary)


but I'm getting these errors:

`/Users/hammadnasir/iOS Projects/Stormy/Stormy/ViewController.swift
/Users/hammadnasir/iOS Projects/Stormy/Stormy/ViewController.swift:17:100: Expected '{' after 'if' condition
/Users/hammadnasir/iOS Projects/Stormy/Stormy/ViewController.swift:19:9: 'let' cannot appear nested inside another 'var' or 'let' pattern
/Users/hammadnasir/iOS Projects/Stormy/Stormy/ViewController.swift:19:9: Getter/setter can only be defined for a single variable
/Users/hammadnasir/iOS Projects/Stormy/Stormy/ViewController.swift:18:62: Use of unresolved identifier 'plistPath'
/Users/hammadnasir/iOS Projects/Stormy/Stormy/ViewController.swift:21:68: Use of unresolved identifier 'currentWeatherDicitonary'`


Thanks in advance.

1 Answer

Jeroen de Vrind
Jeroen de Vrind
29,772 Points

Which version of Swift do u use?

The problem was with my Xcode. After updating it to latest version, the problem is gone.

I'm glad you tried to help!

Thanks anyway.