开发者

Initializing custom init gives "incompatible type for argument 1 of 'initWithCoord:'"

I creating my own class with a custom initWithCoord that takes one (struct CLLocationCoordinate2D*) as parameter.

Even though I think I have the correct parameter type, I still get the "incompatible type for argument 1 of 'initWithCoord:" What am I doing wrong:

PeopleStub.m:

#import "PeopleStub.h"


@implementation PeopleStub


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

    }

    return self; 

}

@en开发者_开发百科d

PeopleStub.h

#import <Foundation/Foundation.h>


@interface PeopleStub : NSObject {

    NSMutableDictionary *people;

}

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

@end

My way of creating an instance of PeopleStub:

PeopleStub *peopleStub = [[PeopleStub alloc] initWithCoord:locationManager.location.coordinate;

Thanks in advance!


You probably want to be passing just the CLLocationCooridnate2D, not a pointer to same as the parameter. So:

-(id)initWithCoord:(CLLocationCoordinate2D)coord;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜