2017-09-26 9 views
2

MKAnnotation annotation 개체에 대한 정의를 포함하지 않는이 IsEmergency라는 변수를 가지고 있지만, 나는이 코드를 실행하면자 마린 C 번호 - IMKAnnotation가 'X'

if (annotation.IsEmergency == "0") 
     { 
      //doStuff(); 
     } 

을 내 annotation 개체가 포함되지 않은 오류가 발생 IsEmergency에 대한 정의입니다. 난 당신이 내 객체가이 변수가 포함되어있는 것을 확인할 수 있습니다 제공 한 스크린 샷에서

enter image description here

.

다음은 전체 오류입니다 :

지도 위임 메소드가 IMKAnnotation을 통과하므로 MKAnnotation 서브 클래스로 캐스팅을 시작하는지
Severity Code Description Project File Line Suppression State 
Error CS1061 'IMKAnnotation' does not contain a definition for 'IsEmergency' and no extension method 'IsEmergency' accepting a first argument of type 'IMKAnnotation' could be found (are you missing a using directive or an assembly reference?)  270 Active 

답변

2

:

var myAnnotation = annotation as `YourMKAnnotationSubClass`; 
if (myAnnotation?.IsEmergency == "0") 
{ 
    //doStuff(); 
} 
+0

SushiHangover을 다시 한 번 구출! –