2017-06-17 69 views
0

我已經通過Cocoapods下載了'GeoJSON'窗格。但是,當我嘗試運行我的應用程序時,我收到以下錯誤。Swift 3 - 錯誤'上下文類型'AnyObject'不能用於字典文字'

錯誤:上下文類型'AnyObject'不能與字典文字一起使用。 (Image)

public var dictionaryRepresentation: [String: Any] { 
     return [ 
      "geometry": [ 
       "coordinates": self.geometryCoordinates, 
       "type": type(of: self).type 
      ], 
      "type": "Feature", 
      "properties": [:] 
     ] 
    } 

回答

0

我解決它像這樣

public var dictionaryRepresentation: [String: Any] { 
     return [ 
      "geometry": [ 
       "coordinates": self.geometryCoordinates, 
       "type": Self.type 
      ] as [String: Any], 
      "type": "Feature", 
      "properties": [:] 
     ] 
    } 
相關問題