1

因此,我正在使用 Alamofire 进行获取,并且根据索引(请参阅 switch currentIndex),我想获得不同的 URL(有效)和一个类(无效)。

Folders 和 Article 类都声明如下:class Folders : Mappableclass Article : Mappable

    var responseMapping:Mappable?
    var URL:String = ""
    switch currentIndex {
    case 0:
        URL = "searchFolderURL".localized + searchString
        responseMapping = Folders
    case 1:
        URL = "searchArticleURL".localized + searchString
        responseMapping = Article
    default:
        print("Something went horribly wrong")
        guard URL != "" else {
            return
        }
    }
    print(URL)

    Alamofire.request(.GET, URL).responseObject { (response: Response<responseMapping, NSError>) in
        if response.result.isSuccess {

当我尝试以下代码时,它会返回下一个错误:'responseMapping' is not a typeCannot assign value of type 'Article.Type' to type 'Mappable?'

我在这里想念什么?

4

0 回答 0