-3

我不知道为什么我一直收到这个错误 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]];

        }
4

1 回答 1

3

让我们看一下您的代码:

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

好吧,正如您所看到的,以 with 开头的行self.speedView.text不以分号结尾,也没有方括号来终止stringWithFormat调用,并且它有一个额外的方括号。

您可能打算这样做:

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

或者:

self.speedView.text = [NSString stringWithFormat:@"%f", [newLocation speed]]; //Show only speed
于 2013-08-18T04:08:21.830 回答