在我的应用程序的某个地方,我想使用“用户位置”。我找到了下面的代码。但是,我收到“未找到属性‘位置’和‘委托’”错误。应用程序变得越来越复杂,我似乎找不到解决方案。我是 xcode 和 Objective-c 的新手。那么你能帮我解决这个问题吗?这是代码:
-(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];
}];
}
先感谢您!