Objective c 初始化自定义初始化将给出“初始化”;';的参数1的类型不兼容;initWithCoord:'&引用;

Objective c 初始化自定义初始化将给出“初始化”;';的参数1的类型不兼容;initWithCoord:'&引用;,objective-c,struct,initialization,location,parameter-passing,Objective C,Struct,Initialization,Location,Parameter Passing,我使用一个自定义initWithCoords创建自己的类,该类将一个(struct-CLLocationCoordinate2D*)作为参数 即使我认为我有正确的参数类型,我仍然得到“initWithCoord参数1的不兼容类型:”我做错了什么: PeopleStub.m: #import "PeopleStub.h" @implementation PeopleStub -(id)initWithCoord:(struct CLLocationCoordinate2D*)coord{

我使用一个自定义initWithCoords创建自己的类,该类将一个(struct-CLLocationCoordinate2D*)作为参数

即使我认为我有正确的参数类型,我仍然得到“initWithCoord参数1的不兼容类型:”我做错了什么:

PeopleStub.m:

#import "PeopleStub.h"


@implementation PeopleStub


-(id)initWithCoord:(struct CLLocationCoordinate2D*)coord{
    if(self = [super init]){
            people = [[NSMutableDictionary alloc] init];

    }

    return self; 

}

@end
人浴缸

#import <Foundation/Foundation.h>


@interface PeopleStub : NSObject {

    NSMutableDictionary *people;

}

-(id)initWithCoord:(struct CLLocationCoordinate2D*)coord;

@end

提前谢谢

您可能只想传递
cllocationcoridnate2d
,而不是指向参数的指针。因此:

-(id)initWithCoord:(CLLocationCoordinate2D)coord;

您可能只想传递
cllocationcoridnate2d
,而不是指向参数的指针。因此:

-(id)initWithCoord:(CLLocationCoordinate2D)coord;

谢谢当我这样做时,我会在'CLLocationCoordinate2D'之前得到'Expected')和'Pervious声明'--(id)initWithCoord:'CLLocationCoordinate2D)coord'。为什么我会这样?感觉它引用了另一个类似的声明。@Nicsoft,听起来您需要同时更新声明(.h)和定义(.m)文件,以便它们与签名匹配。顺便说一句,这基本上是C语言的东西。从长远来看,得到一本关于C语言的好书可能会让你更容易做到这一点。我已经做到了。“以前声明'--(id)initWithCoords:(CLLocationCoordinate2D)Coords')的警告消失,但在'CLLocationCoordinate2D'之前不是错误“预期”)。@Nicsoft,哪一行(.h或.m)得到错误?您能编辑您的应答器以显示准确的当前代码吗?如果我们能看到一些代码,帮助会容易得多。谢谢!当我这样做时,我会在'CLLocationCoordinate2D'之前得到'Expected')和'Pervious声明'--(id)initWithCoord:'CLLocationCoordinate2D)coord'。为什么我会这样?感觉它引用了另一个类似的声明。@Nicsoft,听起来您需要同时更新声明(.h)和定义(.m)文件,以便它们与签名匹配。顺便说一句,这基本上是C语言的东西。从长远来看,得到一本关于C语言的好书可能会让你更容易做到这一点。我已经做到了。“以前声明'--(id)initWithCoords:(CLLocationCoordinate2D)Coords')的警告消失,但在'CLLocationCoordinate2D'之前不是错误“预期”)。@Nicsoft,哪一行(.h或.m)得到错误?您能编辑您的应答器以显示准确的当前代码吗?如果我们能看到一些代码,帮助会容易得多。