Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.