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 trialDave Pinchoff
4,440 PointsWhy 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)
agreatdaytocode
24,757 PointsHave you tried to clean the project? Product > Clean in xCode
Dave Pinchoff
4,440 PointsThat worked... thanks! Can you explain to me why at all? In what cases would I know to use that?
Thanks again!
4 Answers
agreatdaytocode
24,757 PointsProduct > 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
4,440 PointsThanks, 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
4,440 PointsOh.. 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.
agreatdaytocode
24,757 PointsCan you share this via github?
Dave Pinchoff
4,440 PointsI rewrote the exact same code in a new project and it Builds Successfully. Thanks for the suggestions and help!
agreatdaytocode
24,757 PointsOh cool, congrats on fixing it.
Dave Pinchoff
4,440 PointsThanks - it's all about the small victories. :-)
Dave Pinchoff
4,440 PointsDave Pinchoff
4,440 PointsThe title of the question should say named... NOT naped. Thanks.