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

Ben Holland
PLUS
Ben Holland
Courses Plus Student 4,062 Points

Got new code for the location detection

Hey Pasan Premaratne i changed my detection method to use CoreLocation and the location.delegate = self doesn't work. I've added in everything i need to the Info.plist file and it just doesn't work can someone please . help me out the github repo is https://github.com/benhollandY0ung/Weatherly-iOS

1 Answer

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

To set your view controller as a delegate of the CLLocationManager instance, your view controller needs to conform to the CLLocationManagerDelegate protocol. If that doesn't mean anything to you, start here:

In the mean time to make your code work, your class declaration should be as follows:

class ViewController: UIViewController, CLLocationManagerDelegate {

I'll be releasing a course in the near future that covers delegates and protocols.