2013-04-08 58 views
0

我实际上正在设计一个简单的应用程序,以利用核心位置获取位置详细信息并同时显示经纬度。 但是当我运行它,我得到一个错误信息如下:获取关键值编码兼容错误消息

终止应用程序由于未捕获的异常“NSUnknownKeyException”, 原因:“[setValue方法:forUndefinedKey:]: 这个类不是密钥值编码 - 符合纬度的关键。“

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

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。

+0

嗨Raj的问题可能是在初始化你的NSDictionary你的设置值的字典somekey之前首先检查它是否创建只是创建它@ Raj0689 – krishh 2013-04-08 13:11:01

+0

你好sugan!对不起..但你可以有点特定..因为我是新的Objective-C :( – Raj0689 2013-04-08 13:18:57

+0

嗨拉杰你试图设置值的字典中的键不创建只是把NSLog之前设置值字典,如果它是空的(dict)。只要做dictname = [[NSMutableDictionary alloc] init] k.let我知道如果你没有得到 – krishh 2013-04-09 04:26:17

回答

0

检查你的笔尖,看看你是否有一些连接到outlet称为forLatitude。这不是一个核心的位置问题,这是一个插座连接问题

+0

谢谢:)我甚至认为这可能是问题。所以,设计它是全新的,现在它确定:) – Raj0689 2013-04-10 08:42:08

相关问题