Iphone 使用地理位置类生成时出现警告

Iphone 使用地理位置类生成时出现警告,iphone,Iphone,我还在模拟器上工作,正在等待设备上的测试,在等待过程中,我希望与您分享我的代码,希望您能帮助我找出5个警告的原因 我的应用程序由两类组成:CoreLocationController和GeoLocationViewController CoreLocationController是假定充当核心位置管理器委托的类。这个类将从包含原始数据的核心位置框架接收消息,然后稍后将其传递给我们的视图控制器类。 CoreLocationController.h #import <Foundation/Fo

我还在模拟器上工作,正在等待设备上的测试,在等待过程中,我希望与您分享我的代码,希望您能帮助我找出5个警告的原因 我的应用程序由两类组成:CoreLocationController和GeoLocationViewController

CoreLocationController是假定充当核心位置管理器委托的类。这个类将从包含原始数据的核心位置框架接收消息,然后稍后将其传递给我们的视图控制器类。 CoreLocationController.h

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@protocol CoreLocationControllerDelegate
@required
-(void)LocationUpdate:(CLLocation*)location;//Our location updates are sent here
-(void)locationError:(NSError*)error;//Any errors are sent here
@end
@interface CoreLocationController : NSObject<CLLocationManagerDelegate> {

    CLLocationManager *locMgr;
    id delegate;
}
@property(nonatomic,retain)CLLocationManager *locMgr;
@property(nonatomic,assign)id delegate;
@end
GeoLocationViewController.h:

#import <UIKit/UIKit.h>
#import "CoreLocationController.h"
@interface GeoLocationViewController : UIViewController <CoreLocationControllerDelegate> {

    CoreLocationController *CLController;
    IBOutlet UILabel *locLabel;

}
@property (nonatomic,retain)CoreLocationController *CLController;
@end
#import "GeoLocationViewController.h"

@implementation GeoLocationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    CLController=[[CoreLocationController alloc] init];
    CLController.delegate=self;
    [CLController.locMgr startUpdatingLocation];
}

-(void)locationUpdate:(CLLocation *)location    {

    locLabel.text=[location description];

}
-(void)locationError:(NSError *)error   {

    locLabel.text=[error description];
}
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}
- (void)dealloc {

    [CLController release];
    [super dealloc];
}

@end
warning: property 'CLController' requires method '-CLController' to be defined - use @synthesize, @dynamic or provide a method implementation


 warning: property 'CLController' requires the method 'setCLController:' to be defined - use @synthesize, @dynamic or provide a method implementation


 warning: incomplete implementation of class 'GeoLocationViewController'


 warning: method definition for '-LocationUpdate:' not found


warning: class 'GeoLocationViewController' does not fully implement the 'CoreLocationControllerDelegate' protocol
现在查看我收到的警告:

#import <UIKit/UIKit.h>
#import "CoreLocationController.h"
@interface GeoLocationViewController : UIViewController <CoreLocationControllerDelegate> {

    CoreLocationController *CLController;
    IBOutlet UILabel *locLabel;

}
@property (nonatomic,retain)CoreLocationController *CLController;
@end
#import "GeoLocationViewController.h"

@implementation GeoLocationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    CLController=[[CoreLocationController alloc] init];
    CLController.delegate=self;
    [CLController.locMgr startUpdatingLocation];
}

-(void)locationUpdate:(CLLocation *)location    {

    locLabel.text=[location description];

}
-(void)locationError:(NSError *)error   {

    locLabel.text=[error description];
}
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}
- (void)dealloc {

    [CLController release];
    [super dealloc];
}

@end
warning: property 'CLController' requires method '-CLController' to be defined - use @synthesize, @dynamic or provide a method implementation


 warning: property 'CLController' requires the method 'setCLController:' to be defined - use @synthesize, @dynamic or provide a method implementation


 warning: incomplete implementation of class 'GeoLocationViewController'


 warning: method definition for '-LocationUpdate:' not found


warning: class 'GeoLocationViewController' does not fully implement the 'CoreLocationControllerDelegate' protocol
请回答最后一个问题,如果我的构建成功运行,但我的代码没有显示任何有关地理位置的信息,我是否应该等待在设备上测试我的构建以对其进行判断???

第一个警告(以及下两个警告,它们是相同的):

这意味着,在@implementation之后,您需要在GeoLocationViewController.m文件中@synthesis CLController。但是,它仍然可以工作,因为您没有将其作为类内的属性引用(即,您没有使用
self.CLController
引用它,而只是
CLController
。因此只需将
@synthesis-CLController
放在@implementation for GeoLocationViewController.m之后

第二个错误

warning: incomplete implementation of class 'GeoLocationViewController'
warning: method definition for '-LocationUpdate:' not found

您没有在GeoLocationViewController.h文件中指定LocationUpdate作为方法。

在复制粘贴到此处之前,您是否查看了警告?好的,例如,我不知道这是什么:警告:类“GeoLocationViewController”的未完全实现意味着,我始终实现了一些方法,并对其他方法进行了注释:)还有:警告:“GeoLocationViewController”类没有完全实现“CoreLocationControllerDelegate”协议。我应该实现整个协议吗!!或者忽略它您永远不应该忽略警告,尤其是在Objective-C中,因为它们通常会导致运行时崩溃,因为它是一种基于消息的语言-许多东西不会生成编译时错误,但会在运行时崩溃。也就是说,是的,我现在明白问题是什么了:在您的委托中,您定义了LocationUpdate,但在下面,您使用小写L来实现它。尝试在实现中将其更改为大写,以匹配协议