使用Xcode编写应用程序使用"获取当前位置"方法。获得Parse issue, Expected ';' after method prototype
但是当我添加它时,我会继续获得更多错误,所以我假设只是那个错误。我也收到两个语义问题,缺少方法声明的上下文。解析问题在该部分的第1行,语义问题出现在第11和第20行。任何帮助将不胜感激。提前谢谢。
- (IBAction)getCurrentLocation:(id)sender {
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
@end
pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"Failed to Get Your Location"
delegate:nil cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
longitudeLabel.text = [NSString stringWithFormat:@"%.8f",
currentLocation.coordinate.longitude];
latitudeLabel.text = [NSString stringWithFormat:@"%.8f",
currentLocation.coordinate.latitude];
}
}
答案 0 :(得分:0)
xcode不是智能调试器/编译器所以当你得到一个愚蠢的错误时,它可能不是来自它的地方:) 在这种情况下,我认为你错过了#34;#"签署" pragma mark" 这就是为什么Xcode不断给出错误和警告:) 希望它有所帮助