Dictionary 从nsmutablearray到不相关类型mkannotation的swift 2.0案例始终失败,并且未在mapview Pin中设置图像

Dictionary 从nsmutablearray到不相关类型mkannotation的swift 2.0案例始终失败,并且未在mapview Pin中设置图像,dictionary,swift2,xcode7,mkpinannotationview,Dictionary,Swift2,Xcode7,Mkpinannotationview,我正在使用swift 2.1xcode 7,我必须在地图视图中添加多个注释 但这是警告 从NSMutableArray强制转换为不相关的类型MKAnnotation总是失败 关于这个代码 mapView.addAnnotations(表示为![MyAnnotation]) 也许这两个问题都是相关的,请分享你的宝贵知识 关于,Nishant chandwani将aryNotation声明为本机类型[MyAnnotation],而不是一个未指定的NSMutableArray,因为这些类型不相关 va

我正在使用swift 2.1xcode 7,我必须在地图视图中添加多个注释 但这是警告

从NSMutableArray强制转换为不相关的类型MKAnnotation总是失败

关于这个代码

mapView.addAnnotations(表示为![MyAnnotation])

也许这两个问题都是相关的,请分享你的宝贵知识
关于,Nishant chandwani

aryNotation
声明为本机类型
[MyAnnotation]
,而不是一个未指定的
NSMutableArray
,因为这些类型不相关

var aryNotation = [MyAnnotation]()

我无法理解请再描述一些让aryNotation:NSMutableArray=NSMutableArray()我已经这样描述了谢谢你我正在尝试问题是addObject不工作,因为在这段代码之后,这不是一个可变数组它肯定是一个可变数组,但是对于Swift数组,你必须使用语法
aryNotation.append(locationAnnotation)
谢谢你在Yaaaaahuuuuu工作,如果你有时间,请检查我的第二个问题,地图pin图像未设置,但它在旧swift版本中工作,请给我你的邮件id,twitter或facebook我想关注你
 func mapView(mapView: MKMapView,
        viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?{

            if annotation is MyAnnotation == false{
                return nil
            }

            /* First typecast the annotation for which the Map View has
            fired this delegate message */
            let senderAnnotation = annotation as! MyAnnotation

            /* We will attempt to get a reusable
            identifier for the pin we are about to create */
            let pinReusableIdentifier = senderAnnotation.pinColor.rawValue

            /* Using the identifier we retrieved above, we will
            attempt to reuse a pin in the sender Map View */
            var annotationView =
            mapView.dequeueReusableAnnotationViewWithIdentifier(
                pinReusableIdentifier) as? MKPinAnnotationView


                /* If we fail to reuse a pin, then we will create one */
                annotationView = MKPinAnnotationView(annotation: senderAnnotation,
                    reuseIdentifier: pinReusableIdentifier)

               //print("senderAnnotation.getTag = = \(senderAnnotation.getTag)")
               annotationView?.tag = senderAnnotation.getTag


                annotationView!.canShowCallout = true

                if(currentIndex == senderAnnotation.getTag)
                {
                    //print("currentIndex===\(currentIndex)")
                    let pinImage = UIImage(named:"jivemap_pin_o")
                    annotationView!.image = pinImage
                    annotationView!.layer.zPosition = 1
                }else
                {
                let pinImage = UIImage(named:"jivemap_pin_g")
                    annotationView!.image = pinImage
                }


            return annotationView

    }
var aryNotation = [MyAnnotation]()