gpt4 book ai didi

iOS编译错误: No visible @interface for 'setLocationManager' declares the selector

转载 作者:行者123 更新时间:2023-11-29 02:09:26 24 4
gpt4 key购买 nike

我目前正在完成关于#Augmented Reality 的 Ray Wenderlich iOS 教程,我遇到了一个关于在 MainViewController 界面中找不到 setLocationManger 的问题?我该如何解决?

我不明白,因为我认为这包含在 CoreLocation/Corelocation.h 类中。

#import "MainViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface MainViewController () <CLLocationManagerDelegate, MKMapViewDelegate>

@property (weak, nonatomic) IBOutlet MKMapView *mapViewPointer;
@property (nonatomic, strong) CLLocationManager *locationManagerPointer;

@end

@implementation MainViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Roll Tide

[self setLocationManager:[[CLLocationManager alloc] init]];
[_locationManagerPointer setDelegate:self];
[_locationManagerPointer setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[_locationManagerPointer startUpdatingLocation];

最佳答案

@property(非原子,强)CLLocationManager *locationManagerPointer;

locationManagerPointer 重命名为 locationManager 或将 setter 调用为

[self setLocationManagerPointer:[[CLLocationManager alloc] init]];

当您声明属性时,会自动创建 setter 和 getter。

如果您将属性声明为 @property NSString *userName,则会创建一个具有 setUserName 方法的 setter 和 getter userName 方法。您可以通过 [self setUserName:@"fooBar"][self userName] 访问它们。错误的原因是您的属性名称与 setter 的名称不同。

关于iOS编译错误: No visible @interface for 'setLocationManager' declares the selector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29444197/

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