我想在我的应用程序的地图顶部添加这个 UI,以显示驾驶员当前的驾驶速度。我在 main.m 中得到这些错误。为什么,我该如何解决?
使用未声明的标识符 'viewSpeed'
实例方法 '-setViewSpeed:' 未找到(返回类型默认为 'id')
locationmanager.m
预期的 ':'
预期的方法主体
预期的标识符或 '('
缺少 '@end'
#import "locationManager.h"
@implementation locationManager
@synthesize locationManager;
@synthesize fastView;
- (id) init {
self = [super init];
if (self != nil) {
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self; // send loc updates to myself
}
return self;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
NSLog(@"Location: %@", newLocation description);
{
self.currentLocation = newLocation;
BOOL newLocationIsValid = [self isValidLocation:newLocation witholdLocation:oldLocation];
if(newLocationIsValid && oldLocation)
{
int distance = [newLocation distanceFromLocation:oldLocation];
if(distance >2 && distance<10)
{
[self.fastView setText:[NSString stringWithFormat:@"%i meters ", distance]];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)errort
{
NSLog(@"Error: %@", [error description]);
}
@end
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
NSLog (@"%s", __func__);
}
主文件
-(void)userDidLoagin
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)dealloc
{
[userMap release];
[_Speed release];
[viewSpeed release];
[_fastView release];
[super dealloc];
}
- (void)viewDidUnload
{
[userMap release];
userMap = nil;
[self setSpeed:nil];
[self setViewSpeed:nil];
[self setFastView:nil];
[super viewDidUnload];
}