简体   繁体   English

下标swift 2.2的使用不明确

[英]Ambiguous use of subscript swift 2.2

I get an error right before ["toPosition"] saying Ambiguous use of subscript 我在["toPosition"]说下标的用法["toPosition"]之前得到了一个错误

guard let toLoc = self.currentDetailObj!["toPosition"][0] as? PFGeoPoint else {
            return
}

In a previous statement this works fine 在之前的声明中,这很好

    guard let fromLoc = self.currentDetailObj!["fromPosition"] as? PFGeoPoint else{
        return
    }

Why does the first statement not work? 为什么第一个陈述不起作用? I need the position at index 0. 我需要索引0的位置。

Use .first 使用.first

guard let toLoc = self.currentDetailObj?["toPosition"].first as? PFGeoPoint else {
            return
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM