Не могу получить класс Mapkit, метод для компиляции - PullRequest
0 голосов
/ 29 августа 2011

Не удается получить код для компиляции из-за ошибки в - (void) mapView: (MKMapView *) mapView didUpdateUserLocation: (MKUserLocation *) userLocation

метод.xCode 4 говорит, что «u» является необъявленным идентификатором, как и «*»

. Вот код в файле .m:

#import "WhereamiAppDelegate.h"

@implementation WhereamiAppDelegate


@synthesize window=_window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
     // Create location manager object
     locationManager = [[CLLocationManager alloc]init];

    // There will be a warning from this line of code, ignore it for now
    [locationManager setDelegate:self];

    // We want all results from the Location Manager
    [locationManager setDistanceFilter:kCLHeadingFilterNone];

    // And we want it to be as accurate as possible
    // regardless of how much power it takes
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

    // [locationManager startUpdatingLocation];
    [worldView setShowsUserLocation:YES];

    // Tell our manager to start looking for its location immediately
    [locationManager startUpdatingLocation];

    [self.window makeKeyAndVisible];
    return YES;
}

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation 
           fromLocation:(CLLocation *)oldLocation
 {
   NSLog(@"%@", newLocation);
 }

- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error
{
    NSLog(@"Could not find location: %@", error);
}

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation   *)userLocation
{
    CLLocationCoordinate2D loc = [u coordinate]; 
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250); 
    [worldView setRegion:region animated:YES];
}

Скажите, пожалуйста, чтоМне нужно сделать, чтобы преодолеть эту проблему и заставить программу скомпилироваться?

Спасибо.

1 Ответ

0 голосов
/ 29 августа 2011

Попробуйте

- (void)mapView:(MKMapView*)mapView didUpdateUserLocation:(MKUserLocation*)userLocation
{
    CLLocationCoordinate2D loc = [userLocation coordinate]; 
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250); 
    [worldView setRegion:region animated:YES];
}

Ваша вырезка и вставка пропустили serLocation из userLocation .

...