【发布时间】:2011-07-07 21:18:58
【问题描述】:
我使用自定义 initWithCoord 创建自己的类,该类以一个 (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
PeopleStub.h
#import <Foundation/Foundation.h>
@interface PeopleStub : NSObject {
NSMutableDictionary *people;
}
-(id)initWithCoord:(struct CLLocationCoordinate2D*)coord;
@end
我创建 PeopleStub 实例的方式:
PeopleStub *peopleStub = [[PeopleStub alloc] initWithCoord:locationManager.location.coordinate;
提前致谢!
【问题讨论】:
标签: objective-c struct initialization location parameter-passing