Цель C: странная ошибка при инициализации переменной, объявленной в моем заголовочном файле - PullRequest
0 голосов
/ 04 декабря 2010

Я получаю, когда добавляю эту строку:

locMan = [[CLLocationManager alloc] init];

В методе viewDidLoad внутри моего файла .m я получаю некоторые ошибки, которых я никогда раньше не видел Вот ошибки:

alt text

Я не могу понять, почему добавление этой строки вызывает проблемы. Если кто-то может пролить свет, я был бы очень благодарен.

У меня есть этот заголовочный файл:

#import <UIKit/UIKit.h>
#import "CoreLocation/CoreLocation.h"


@interface RobotWarsViewController : UIViewController 
<CLLocationManagerDelegate> {

    CLLocationManager *locMan;

    // Current Location View
    IBOutlet UIView  *currentLocationView;
    IBOutlet UILabel *currentLocationLabel;


}

@property (assign, nonatomic) UIView  *currentLocationView;
@property (assign, nonatomic) UILabel *currentLocationLabel;
@property (assign, nonatomic) CLLocationManager *locMan;                           

- (IBAction)dropEMP:(id)sender;
- (IBAction)armEMP:(id)sender;

@end

И этот файл .m:

#import "RobotWarsViewController.h"

@implementation RobotWarsViewController


@synthesize locMan;
@synthesize currentLocationView;
@synthesize currentLocationLabel;

- (void)viewDidLoad {
    [super viewDidLoad];

    locMan = [[CLLocationManager alloc] init];
//  locMan.delegate = self;

}

- (IBAction)dropEMP:(id)sender{

    NSLog(@"Boo");

}

- (IBAction)armEMP:(id)sender{

    NSLog(@"boo");

}

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
           fromLocation:(CLLocation *)oldLocation {

    NSLog(@"location update");

}



- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [super dealloc];
    [currentLocationView release];
    [currentLocationLabel release];

}

@end

Ответы [ 2 ]

3 голосов
/ 04 декабря 2010

Вы добавили инфраструктуру CoreLocation в свой проект?

Разверните группу Frameworks и посмотрите, есть ли там CoreLocation. Если нет, щелкните по нему правой кнопкой мыши и добавьте.

2 голосов
/ 04 декабря 2010

Вы не добавили инфраструктуру CoreLocation в свой проект.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...