iOS:使用HanekeSwift和SwiftyJSON [英] iOS: Using HanekeSwift with SwiftyJSON

查看:336
本文介绍了iOS:使用HanekeSwift和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆