Somewhere in my application I want to use ‘user location’. I found the code below. However, I get a “property ‘location’ and ‘delegate’ not found” errors. The application is getting more complex, and I can’t seem to find the solution. I’m new to xcode and objective-c. So will you please help me on that?
Here is the code:
-(void)getUserLocation{
self.geoCoder = [[CLGeocoder alloc] init];
self.locationMng = [[CLLocationManager alloc]init];
locationMng.delegate = self;
[self.geoCoder reverseGeocodeLocation: locationMng.location completionHandler:
^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSLog(@"I am currently at %@",locatedAt);
[locationLabel setText:locatedAt];
}];
}
Thank you in advance!
As it follows from comments you have declared property
locationMngincorrectly.Try this: