gpt4 book ai didi

iphone - CLLocation 可能不会响应 setDistanceFilter

转载 作者:行者123 更新时间:2023-11-28 18:26:43 25 4
gpt4 key购买 nike

我是 iPhone 编程的新手,我正在关注 this书。我停留在第 4 章委托(delegate)和核心位置中的示例。

这是我到目前为止编写的代码:其中amiAppdelegate.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

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

 - (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);
}

XCode 给我一个警告,说 CLLocation 可能不会响应 setDistanceFilter 和其他类似的警告。我在这里一无所知,我已经按照书行进行了。我认为我没有实现必要的协议(protocol)或其他东西。有人可以告诉我我做错了什么以及我应该如何进一步处理。

最佳答案

类(class)CLLocationCLLocationManager 不同.前者代表一个位置,而后者是为您的应用程序处理配置位置更新的管理器类。

关于iphone - CLLocation 可能不会响应 setDistanceFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7164179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com