简体   繁体   中英

Ambiguous use of subscript swift 2.2

I get an error right before ["toPosition"] saying Ambiguous use of subscript

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.

Use .first

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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