Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将viewcontroller连接到代理类-CLLocationManager/iOS8_Ios_Objective C_Iphone_Uiviewcontroller_Delegates - Fatal编程技术网

将viewcontroller连接到代理类-CLLocationManager/iOS8

将viewcontroller连接到代理类-CLLocationManager/iOS8,ios,objective-c,iphone,uiviewcontroller,delegates,Ios,Objective C,Iphone,Uiviewcontroller,Delegates,尝试将视图控制器链接到委托类(实现CLLocation回调)时,初始化委托时出错 我的VC.h: @interface ViewController : UIViewController <MyLocationControllerDelegate> { MyLocationController *CLController; } 我注意到这个错误在以前的iOS版本中没有出现 谢谢你的帮助 根据,MyLocationController必须符合CLLocationManagerDe

尝试将视图控制器链接到委托类(实现CLLocation回调)时,初始化委托时出错

我的VC.h:

@interface ViewController : UIViewController <MyLocationControllerDelegate> {
  MyLocationController *CLController;
}
我注意到这个错误在以前的iOS版本中没有出现

谢谢你的帮助

根据,
MyLocationController
必须符合
CLLocationManagerDelegate

@interface MyLocationController: NSObject <CLLocationManagerDelegate>

@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, weak) id delegate;

@end
@接口MyLocationController:NSObject
@属性(非原子,强)CLLocationManager*locationManager;
@属性(非原子,弱)id委托;
@结束

作为旁注,您不需要为属性
locationManager
delegate
声明IVAR。iVars
\u locationManager
\u委托将自动为您生成。

感谢@jeffery的编辑!还不知道怎么做..您的协议声明为空。您的MyLocationControllerDelegate定义在哪里?谢谢,就这样!附带问题,由于某种原因,当回调函数didUpdateLocations:位于单独的类中时,我没有收到任何回调。你知道会出什么问题吗?我用上下文的更多信息更新了我的描述。谢谢你的帮助!
- (id)init 
{
    self = [super init];

    if(self != nil) {
        self.locationManager = [[CLLocationManager alloc] init]; // Create new instance of locationManager
        self.locationManager.delegate = self; // Set the delegate as self.

    }

    return self;
}
@interface MyLocationController: NSObject <CLLocationManagerDelegate>

@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, weak) id delegate;

@end