I am actually designing a simple app to make use of the core location to get the location details and at the same time, displaying the latitude and longitude. But when I run it, I get an error message as below:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key forLatitude.'
I have synthesised the properties too. I still do not know the exact reason as to why it is throwing up an error !
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];
}
}
Any help would be much appreciated.
Thanks and Regards, Raj.