【问题标题】:Core Location - Property 'location' not found核心位置 - 未找到物业“位置”
【发布时间】: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


【解决方案1】:

从 cmets 得出,您错误地声明了属性 locationMng

试试这个:

@property (retain, nonatomic) CLLocationManager *locationMng; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    • 2011-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多