Я пытаюсь создать приложение для 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 ответ
Замените свой код этим.
-(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];
}
Похожие вопросы
Новые вопросы
xcode4
Xcode 4, выпущенный в июне 2011 года, представляет собой интегрированную среду разработки Apple (IDE) для Mac OS X и iOS. Этот тег следует использовать только для вопросов об этой конкретной версии XCode, а не для общих тем программирования для Mac или iOS. Используйте [какао] для вопросов программирования Mac или [какао-touch] для вопросов программирования iOS (ранее iPhone OS).