我嘗試訪問我的枚舉,但它不工作!枚舉 - 無法識別的選擇發送到實例
我做一個typedef枚舉我Annotation.h和我嘗試在其他類來訪問枚舉的一個元素......
typedef enum
{
AnnotationTypeMale = 0,
AnnotationTypeFemale = 1
} AnnotationType;
@interface Annotation : NSObject <MKAnnotation>
{
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
AnnotationType annotation_type;
}
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic,retain) NSString *title;
@property (nonatomic,retain) NSString *subtitle;
@property (nonatomic,getter=getAnnotationType,setter=setAnnotationType) AnnotationType annotation_type;
@end
這是我Annotation.h,在我Annotation.mi合成所有和我包括Annotation.h也... 我在其他類我現在嘗試訪問AnnotationType ...
- (AnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation
{
AnnotationView *annotationView = nil;
// determine the type of annotation, and produce the correct type of annotation view for it.
Annotation* myAnnotation = (Annotation *)annotation;
if([myAnnotation getAnnotationType] == AnnotationTypeMale)
{
如果語句犯規work..this發生錯誤:終止應用程序由於未捕獲的異常' NSInvalidArgumentException',原因:' - [MKUserLocation getAnnotationTyp E]:無法識別的選擇發送到實例0x5c43850'
任何解決方案?????? THX
哎! !謝謝4你的帖子問題是固定的:) – Kun19 2011-03-06 16:33:08
我採取了第一個解決方案;) – Kun19 2011-03-06 16:33:34