0

在我的应用程序的某个地方,我想使用“用户位置”。我找到了下面的代码。但是,我收到“未找到属性‘位置’和‘委托’”错误。应用程序变得越来越复杂,我似乎找不到解决方案。我是 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];

 }];

} 

先感谢您!

4

1 回答 1

0

从评论中可以看出,您locationMng错误地声明了属性。

试试这个:

@property (retain, nonatomic) CLLocationManager *locationMng; 
于 2012-10-01T22:48:15.587 回答