预期Xcode解析问题']'

时间:2013-08-18 04:01:56

标签: iphone ios 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]];

        }

1 个答案:

答案 0 :(得分: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