1

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

}

1 Answers1

0

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];
}
Baby Groot
  • 4,637
  • 39
  • 52
  • 71
  • try this https://www.google.co.in/search?q=learning+objective+c&aq=f&oq=learning+objective+c&aqs=chrome.0.57j0l3j62l2.8182j0&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=learning+objective+c+basics&oq=learning+objective+c+basics&gs_l=serp.3..0i22i30.11529.13835.0.14370.7.3.0.4.4.0.139.355.1j2.3.0...0.0...1c.1.8.psy-ab.4njagVi2l9E&pbx=1&bav=on.2,or.r_cp.r_qf.&bvm=bv.44770516,d.bmk&fp=a87c72b3a05aaf8c&biw=1024&bih=591 – Baby Groot Apr 05 '13 at 11:21