На самом деле я разрабатываю простое приложение, чтобы использовать основное местоположение для получения сведений о местоположении и в то же время отображать широту и долготу. Но когда я запускаю его, я получаю сообщение об ошибке, как показано ниже:
Завершение работы приложения из-за необработанного исключения "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];
}
}
Любая помощь приветствуется.
Спасибо и С уважением, Радж.