Question

I am trying to create a app for IOS for "Sphero", and I want to test the HelloWorld sample however after creating a new project I click build and it fails and I get 4 problems:

1) Use af undeclared identifier 'viewDidLoad':

 -(void)viewDidLoad {

2) Missing "[" at start of message send expression this is in the following code line, xcode wants to put the [ in before the second "selector"

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

3) Bad receiver type 'SEL' (in the same line as above)

4) Expected external declaration:

The last curly bracket comes up as wrong.

-(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];
}

}
Was it helpful?

Solution

Replace your code with this.

-(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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top