CLLocation可能无法响应setDistanceFilter

nik*_*hil 0 iphone core-location ios

我是iPhone的编程新手,我跟着本书.我坚持第4章,授权和核心位置的例子.

这是我到目前为止编写的代码:WhereamiAppdelegate.h

    #import <UIKit/UIKit.h>
    #import <CoreLocation/CoreLocation.h>

    @interface WhereamiAppDelegate : NSObject <UIApplicationDelegate, CLLocationManagerDelegate> {
        UIWindow *window;
        CLLocation *locationManager;

    }

    @property (nonatomic, retain) IBOutlet UIWindow *window;

    @end
Run Code Online (Sandbox Code Playgroud)

这是实现文件:我只包含了我所做的更改.整个文件都在这里.

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Create location manager.
        locationManager = [[CLLocation alloc] init];
        [locationManager setDelegate:self];
        [locationManager setDistanceFilter:kCLDistanceFilterNone];
        [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
        [locationManager startUpdatingLocation];

    [self.window makeKeyAndVisible];
    return YES;
}

- (void)dealloc
{
    [locationManager setDelegate:nil];
    [_window release];
    [super dealloc];
}

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

- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error
{
    NSLog(@"Couldn't find loaction %@",error);
}
Run Code Online (Sandbox Code Playgroud)

XCode给我一个警告,说CLLocation可能不响应setDistanceFilter和其他类似的警告.我在这里一无所知,我已按照书中的说法排成一行.我认为我还没有实施必要的协议.有人可以告诉我我做错了什么以及我应该如何进一步.

Ano*_*mie 5

班级CLLocation不一样CLLocationManager.前者代表一个位置,而后者是管理器类,用于处理为应用程序配置位置更新.