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 (Retired) Pulling Data From the Web Networking in iOS

Dave Pinchoff
Dave Pinchoff
4,440 Points

Why am I getting this error? ViewController.type does not have a member named 'apiKey'

I am receiving this error for the line of code for the baseURL constant as well as the forecastURL constant, but there it says named 'baseURL', obviously... Here is my code with the apiKey String x'd out...

Thanks so much for any and all help!

class ViewController: UIViewController {

    private let apiKey="xxxxx"

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
    let forecastURL = NSURL(string: "42.9, 78.85", relativeToURL: baseURL)
Dave Pinchoff
Dave Pinchoff
4,440 Points

The title of the question should say named... NOT naped. Thanks.

Have you tried to clean the project? Product > Clean in xCode

Dave Pinchoff
Dave Pinchoff
4,440 Points

That worked... thanks! Can you explain to me why at all? In what cases would I know to use that?

Thanks again!

4 Answers

Product > Clean in xCode

When you build for the first time, all of your code is turned into object code. That way when you make a tiny change to one file, you don't have to recompile your whole project, just that one file.

Now sometimes things go funny and stuff doesn't align properly, or dependencies aren't updated and boom crash. The build system is supposed to detect this but every project I've worked on has had this problem at one time or another.

Build clean deletes all the intermediate object code and recompile from scratch.

Dave Pinchoff
Dave Pinchoff
4,440 Points

Thanks, again... Really appreciate the help - I was at a stand still and left trying to answer other people's questions in the forums! :-)

Dave Pinchoff
Dave Pinchoff
4,440 Points

Oh.. I spoke too soon... It looked like it was better right after the clean up, but then when I went to Build the program, it failed and the same errors came up.

Any other ideas would be appreciated!!! Thanks, again.

Can you share this via github?

Dave Pinchoff
Dave Pinchoff
4,440 Points

I rewrote the exact same code in a new project and it Builds Successfully. Thanks for the suggestions and help!

Oh cool, congrats on fixing it.

Dave Pinchoff
Dave Pinchoff
4,440 Points

Thanks - it's all about the small victories. :-)