2013-08-18 82 views
-3

我不知道爲什麼我不斷收到這個錯誤解析問題預期']',任何幫助將不勝感激。Xcode Parse Issue Expected']'

locationManager didUpdateToLocation FromLocation 
     - (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
    fromLocation:(CLLocation *)oldLocation { 
     NSLog(@"%@", newLocation); 
     self.speedView.text = [[NSString stringWithFormat:@"%d", (speedCount) 
    I Receive the error on this line [newLocation speed]]; 

     } 
+0

你能格式化你的問題好一點。這很難閱讀 – Iowa15

+0

錯誤信息說明了一切。看起來你有太多的]。數它們,看看它們是否匹配。 – Aaron

+0

是的,這是問題,感謝您的幫助球員 – mrorgon

回答

3

讓我們來看看你的代碼:

- (void)locationManager:(CLLocationManager *)manager 
     didUpdateToLocation:(CLLocation *)newLocation 
     fromLocation:(CLLocation *)oldLocation 
{ 
    NSLog(@"%@", newLocation); 
    self.speedView.text = [[NSString stringWithFormat:@"%d", (speedCount) 
    [newLocation speed]]; 
} 

好吧,你可以看到,與self.speedView.text盯着行不以分號結束,它也沒有一個方形支架終止stringWithFormat通話,它有一個額外的方括號。

你可能打算這樣做:

self.speedView.text = [NSString stringWithFormat:@"%d %f", speedCount, [newLocation speed]]; //Show both speedCount and speed in your text view(?) 

OR:

self.speedView.text = [NSString stringWithFormat:@"%f", [newLocation speed]]; //Show only speed 
+0

非常感謝,我得到它運行沒有錯誤。 – mrorgon

+0

沒問題!出於好奇,你打算做哪一件?另外,不要忘記接受幫助你/給你解決問題的答案! –

+1

第一個self.speedView.text = [NSString stringWithFormat:@「%d%f」,speedCount,[newLocation speed]];並沒有問題。 – mrorgon