Self Location Manager Delegate error in Xcode 6

夙愿已清 提交于 2019-12-24 17:00:02

问题


I'm using code from: http://www.veasoftware.com/tutorials/2014/6/17/xcode-5-tutorial-ios-7-simple-compass-app In Xcode 6 I get the error below. The app still runs, but this error is really annoying me.

self.locationManager.delegate = self;
//Assigning to 'id<CLLocationManagerDelegate>' from incompatible type 'ViewController *const __strong'

回答1:


I guess you forgot to comply with the Core Location Delegate protocol by adding <CLLocationManagerDelegate> after @interface in the header file.




回答2:


Try this:

1)Make your class import the below:

#import<CoreLocation/CoreLocation.h>

2) Make you class adopt the protocol:

interface YourClassName : UIViewController <CLLocationManagerDelegate>

3) In Last option to suppress it by doing:

self.locationManager.delegate = (id)self; 

The warning should be gone now.




回答3:


self.locationManager.delegate = (id)self;


来源:https://stackoverflow.com/questions/26078133/self-location-manager-delegate-error-in-xcode-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!