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

标签 ios objective-c iphone xcode6

我目前正在完成关于#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/

相关文章:

ios - 调整 SearchResultsTableView 的大小

iphone - 从 iOS 应用程序将音频上传到 Facebook?

iphone - iOS:从 AppDelegate 访问导航 View Controller

iphone - 在 iphone 中解析字符串 json 值?

ios - 我的导航栏的色调会自动改变

ios - 根据出生日期计算年龄

objective-c - 追踪执行executeFetchRequest时导致卡住的 block /死锁

ios - 出现键盘时如何使键盘以外的其他界面不可用?

iphone - 在 UIImageView 中调整 UIImage 的大小

ios - 在搜索按钮上隐藏键盘单击代码创建的搜索栏