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": [:] 
     ] 
    } 
相关问题