2013-04-04 73 views
1

我想創建iOS版應用的「Sphero」,我想創建一個新的項目,我單擊生成後然而測試HelloWorld樣品和失敗,我得到4個問題:SPHERO建立失敗的Xcode4

1)使用AF未聲明的標識符「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]; 
} 

} 

回答

0

用這個代替你的代碼。

-(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

如果我和你發佈的代碼運行I 8新的錯誤: – 2013-04-05 11:19:21

+0

試試這個https://www.google.co.in/search?q=learning+objective+c&aq=f&oq=learning+objective + C&AQS = chrome.0.57j0l3j62l2.8182j0&的SourceID =鉻&即= UTF-8#HL = EN&sclient = PSY-AB&q =學習+客觀+ C +基礎和OQ =學習+客觀+ C +基礎&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&波黑= 591 – 2013-04-05 11:21:46