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

Anthony Ho
Anthony Ho
10,228 Points

I want to learn how to use the forecast.io api in objective-C.

what's the equivalent of private let in objective-C Swift has Access Controls. I was wondering if i can do the same for Obj-C and make a similar app

In addition I want to use CoreLocation to find current location to find current weather and updates every times a user taps refresh

1 Answer

An iOS X-Code Project template for Forecast.io which is written in Obj-C which should provide a good starting point is here, https://github.com/brandonemrich/ForecastKit. I believe it will need the AFNetworking library via CocoaPods also. There are plenty of CoreLocation tutorials on the net but in iOS 8 you will need to add usage descriptions in the app's plist and a 'usage request' before implementing it's delegate or any other of it's methods.

For example

locationManager.requestWhenInUseAuthorization()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
locationManager.startUpdatingLocation()

For declaring constants in Obj-C would be something like this:

static NSString *const kConstant = @"myconstant";