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 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'`

Please HELP ASAP!

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.