Я пытаюсь создать приложение для IOS для "Sphero", и я хочу протестировать образец HelloWorld, однако после создания нового проекта я нажимаю "build", и он терпит неудачу, и у меня возникают 4 проблемы:

1) Используйте необъявленный идентификатор 'viewDidLoad':

 -(void)viewDidLoad {

2) Отсутствует "[" в начале выражения отправки сообщения это в следующей строке кода, xcode хочет поставить [перед вторым «селектором»

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];

3) Неверный тип приемника 'SEL' (в той же строке, что и выше)

4) Ожидаемое внешнее объявление:

Последняя фигурная скобка оказывается неправильной.

-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
-(void)viewDidLoad {
    [super viewDidLoad];

    /*Register for application lifecycle notifications so we known when to connect and disconnect from the robot*/
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];

    /*Only start the blinking loop when the view loads*/
    robotOnline = NO;

    calibrateHandler = [[RUICalibrateGestureHandler alloc] initWithView:self.view];
}

}
1
Christian Nicolaisen 4 Апр 2013 в 12:28

1 ответ

Лучший ответ

Замените свой код этим.

-(void)viewDidLoad {
    [super viewDidLoad];

    /*Register for application lifecycle notifications so we known when to connect and disconnect from the robot*/
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];

    /*Only start the blinking loop when the view loads*/
    robotOnline = NO;

    calibrateHandler = [[RUICalibrateGestureHandler alloc] initWithView:self.view];
}
0
Baby Groot 4 Апр 2013 в 21:16
Попробуйте это Baby Groot
5 Апр 2013 в 15:21