kareem
kareem

Reputation: 933

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.

Upvotes: 0

Views: 110

Answers (1)

ZYiOS
ZYiOS

Reputation: 5280

Use .first

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

Upvotes: 0

Related Questions