iOS:使用HanekeSwift和SwiftyJSON [英] iOS: Using HanekeSwift with SwiftyJSON
问题描述
我在当前的快速项目中使用Alamofire和SwiftyJSON。
我想添加HanekeSwift进行缓存。
I use Alamofire with SwiftyJSON in my current swift project. I would like to add HanekeSwift for caching.
将HanekeSwift添加到项目中使其与SwiftyJSON struct JSON冲突。
Adding HanekeSwift to the project make it "collide" with SwiftyJSON struct JSON.
有没有简单的方法使用这两个框架?
我知道有一个选项可以重命名其中一个JSON结构,但看起来像是一个愚蠢的解决方法。或者做一些名称空间的事情。
Is there any easy way to use both of these frameworks? I know there is a option to rename one of the JSON structs but seems like a stupid workaround. Or do some namespace thing.
错误信息:
'JSON' is ambiguous for type lookup in this context
对此有任何解决方案吗?
Any solutions to this?
推荐答案
因此,我发现的解决方案对我来说只是声明您尝试使用的完整类型的JSON对象。例如。 - 在期望或使用SwiftyJSON结构时声明SwiftyJSON.JSON而不仅仅是JSON,或者当你想使用Haneke的JSON枚举时声明Haneke.JSON。
So, the solution that I've found works for me is just to declare the full type of JSON object you are trying to use. E.g. - declare SwiftyJSON.JSON rather than just JSON when expecting or using a SwiftyJSON struct, or Haneke.JSON when you want to use Haneke's JSON enum.
例如,对于SwiftyJSON :
For example, for SwiftyJSON:
var json = SwiftyJSON.JSON(inputObject!)
或对于Haneke:
var json = Haneke.JSON(inputObject!)
这篇关于iOS:使用HanekeSwift和SwiftyJSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!