敏捷的如何从协议中导入的库中声明返回类型为func



我在带有cocoapods的proj中使用了许多库。它需要将这些库导入到我使用其中类实例的文件中

今天,我决定创建协议,其中一个声明的函数必须从导入的库返回类型:

import SwiftyJSON
protocol ContainsProductsList {
    func productsSummaryPrice() -> Int
    func productsCount() -> Int
    func productsAvailability(date : String) -> Calendar.Availability
    func JSON() -> JSON
}

但编译器不允许我这样做(使用未声明的类型"JSON")。我试图将协议放在另一个使用SwiftyJSON库的文件中,但结果是一样的。你能解释一下为什么会这样吗?也许有办法绕过这个?

使用正确的方法命名:

protocol ContainsProductsList {
    func productsSummaryPrice() -> Int
    func productsCount() -> Int
    func productsAvailability(date : String) -> Calendar.Availability
    func JSONMYFUNCTION() -> JSON
}

最新更新