|  |      1ultragtx      2012-02-25 14:09:54 +08:00 .h @interface AdoptingAnAnnotation: NSObject <MKAnnotation> {} // 加上MKAnnotation 的protocol @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; @property (nonatomic, readonly, copy) NSString *title; @property (nonatomic, readonly, copy) NSString *subtitle; // title 和 subtitle按你之前的写也没啥事 @end .m @synthesize coordinate; // @synthesize 是跟 @property 配合的 详细去看文档 Advanced Memory Management 貌似叫这个 @synthesize title, subtitle; - (id) initWithLatitude:(CLLocationDegrees) lat longitude:(CLLocationDegrees) lng { self = [super init] if (self) { coordinate.latitude = lat; coordinate.longitude = lng; } return self; } - (NSString *) title { return @"217 2nd St"; } - (NSString *) subtitle { return @"San Francisco CA 94105"; } @end // 这样差不多了吧 新手就看文档 多参考文档中的sample project 多看看xxxxx Guide 另外先把objc的基本内容弄明白 | 
|  |      2ultragtx      2012-02-25 14:11:15 +08:00 话说v2ex里会不会有用户名为property end synthesize implementation的人在啊 | 
|  |      3yishenggudou OP @ultragtx 额....  可以赶紧抢注一个 | 
|  |      4yishenggudou OP @ultragtx 谢谢鼓励 原来这个叫  Advanced Memory Management | 
|  |      5yishenggudou OP @ultragtx 再请教下,这个class写好之后 怎么加到Mapview上? map addAnnotation: 这个后面怎么调用这个类? | 
|  |      6ultragtx      2012-02-25 15:06:46 +08:00 AdoptingAnAnnotation *annotation = [[AdoptingAnAnnotation alloc] initWithLatitude:lat longitude:lon]; [mapView addAnnotation:annotation]; | 
|  |      7yishenggudou OP @ultragtx 谢谢..前面这个AdoptingAnAnnotation 是根据类名来把,类名叫什么就是什么?   我发现我真的太菜了  sigh... | 
|  |      8ultragtx      2012-02-25 15:23:02 +08:00 刚开始都这样 硬着头皮上 写多了自然就会了 | 
|  |      9yishenggudou OP @ultragtx 恩 ...谢谢鼓励 |