【问题标题】:Getting a Key value coding compliant error message获取符合键值编码的错误消息
【发布时间】:2013-03-30 13:51:45
【问题描述】:

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

由于未捕获的异常“NSUnknownKeyException”而终止应用程序, 原因:'[setValue:forUndefinedKey:]: 此类对于 Latitude 键的键值编码不兼容。'

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

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,问题可能出在初始化你的 NSDictionary 之前,你在字典中为 somekey 设置值首先检查它是否没有创建,只需创建它@Raj0689
  • 嗨,苏甘!对不起..但是你能不能具体一点..因为我是objective-C的新手:(
  • 嗨,你正在尝试为未创建的字典中的键设置值,如果它是 null(dict),则在将值设置为 dict 之前放置 NSLog。只需执行 dictname=[[NSMutableDictionary alloc]init ] k.如果你没有得到,请告诉我
  • 或者直接在 NSLog 中打印你的回复

标签: xcode ios6 core-location cllocationmanager


【解决方案1】:

检查您的笔尖,看看您是否与名为 forLatitude 的插座有某种连接。不是核心位置问题,这是插座连接问题

【讨论】:

  • 谢谢 :) 我什至认为这可能是问题所在。所以,将它设计成全新的,现在可以了 :)
猜你喜欢
  • 2017-10-24
  • 1970-01-01
  • 2019-06-23
  • 1970-01-01
  • 2017-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多