获取符合键值编码的错误消息



我实际上是设计一个简单的应用程序,使利用核心位置获得位置的详细信息,并在同一时间,显示纬度和经度。但是当我运行它时,我得到如下错误消息:

由于未捕获异常'NSUnknownKeyException'而终止应用程序,原因:'[setValue:forUndefinedKey:]:这个类的键值编码与forLatitude键不兼容。

我也合成了这些属性。我仍然不知道它抛出错误的确切原因!

rajViewController.h

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface rajViewController : UIViewController <CLLocationManagerDelegate>

@property (weak, nonatomic) IBOutlet UILabel *latitudeLabel;
@property (weak, nonatomic) IBOutlet UILabel *longitudeLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
- (IBAction)getCurrentLocation:(id)sender;
@end

rajViewController.m

@interface rajViewController (){
    CLLocationManager *locationManager;
    CLGeocoder *geo;
    CLPlacemark *placemark;
}

@end
@implementation rajViewController
//@synthesize placemark;
@synthesize latitudeLabel;
@synthesize longitudeLabel;
.
.
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    CLLocation *newPlace = [[CLLocation alloc]init];
    newPlace = [locations lastObject];
    NSLog(@"the latitude is : %f",newPlace.coordinate.latitude);
    if (newPlace!=nil){
        self.latitudeLabel.text = [NSString stringWithFormat:@"%f", newPlace.coordinate.latitude];
        self.longitudeLabel.text = [NSString stringWithFormat:@"%f",newPlace.coordinate.longitude];
    }
}

任何帮助都将非常感激。

谢谢Raj .

检查你的笔尖,看看你是否有一些连接到outlet调用forLatitude。这不是核心位置问题,这是出口连接问题

相关内容

最新更新