0
我在与MKAnnotation问题
,我创建了一个类“cgdMapAnnotation”的注解,它的构造函数的一个是这样的:MKAnnotation构造错误
+ (id) initWithCoordinate:(CLLocationCoordinate2D)coordinate andTitle:(NSString*) title andSubtitle:(NSString*) subtitle {
self = [super alloc];
_coordinate = coordinate;
_title = [title retain];
_subtitle = [subtitle retain];
return self;
}
的问题是,当我打电话:
cgdMapAnnotation *placemark=[[[cgdMapAnnotation alloc] initWithCoordinate:centerCoordinate andTitle:@"Title" andSubtitle:@"SubTitle" ] autorelease];
我在控制台收到以下错误:
-[cgdMapAnnotation initWithCoordinate:andTitle:andSubtitle:]: unrecognized selector sent to instance 0x33cf2fe0
我真的不了解什么是问题。有人可以帮忙吗?
在此先感谢。
谢谢!就是这样。这是我的第一个iPhone项目,所以只是一个新手。顺便说一下,类方法中的“ - ”和“+”有什么区别? “ – Rui 2011-04-19 18:56:41
”+“表示类方法,因此可以在类对象上调用它。 UIButton的buttonWithType就是一个例子。所以你可以调用[UIButton buttonWithType:TYPE]。 “ - ”表示一个实例方法,因此它在一个类的实例上被调用。一个例子就是UIButton的imageForState。所以你可以调用[someButton imageForState:STATE]。 – cgarman 2011-04-19 20:28:31
谢谢!真的很感谢帮助。 – Rui 2011-04-19 22:21:35