【发布时间】:2012-10-01 22:38:14
【问题描述】:
我想在我的应用程序的某个地方使用“用户位置”。我找到了下面的代码。但是,我收到“未找到属性‘位置’和‘委托’”错误。应用程序变得越来越复杂,我似乎找不到解决方案。我是 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];
}];
}
提前谢谢你!
【问题讨论】:
-
您是否在该文件中导入了
#import <CoreLocation/CoreLocation.h>? -
@nekto 是的,这是我检查的第一件事。
-
你是如何声明
locationMng的? -
这里:@property (retain, nonatomic) IBOutlet NSObject *locationMng;
-
天哪!谢谢内克托!我找了几个小时 x|
标签: xcode core-location