进口后Alamofire无法正常工作

时间:2017-01-11 11:04:14

标签: ios swift xcode cocoapods alamofire

我正在学习Udemy课程,其中使用Alamofire将数据从API下载到Xcode项目。

然而,在安装Alamofire并将其导入我的swift文件后,它无法识别与Alamofire有关(除了一件事:AlamofireVersionNumber)。

我有Alamofire,Xcode和Cocoapods的最新更新,我无法弄清楚出了什么问题。下面我已经把我的swift文件和Alamofire示例放在了我想用GET请求实现的目的。

Swift文件:

import Foundation
import Alamofire

class Pokemon {

fileprivate var _name: String!
fileprivate var _pokedexID: Int!
fileprivate var _description: String!
fileprivate var _type: String!
fileprivate var _defense: String!
fileprivate var _height: String!
fileprivate var _weight: String!
fileprivate var _attack: String!
fileprivate var _nextEvolutionTxt: String!
fileprivate var _nextEvolutionName: String!
fileprivate var _nextEvolutionId: String!
fileprivate var _nextEvolutionLevel: String!
fileprivate var _pokemonURL: String!

var name: String {

    return _name

}

var pokedexID: Int {

    return _pokedexID

}

init(name: String, pokedexID: Int) {

    self._name = name
    self._pokedexID = pokedexID

    self._pokemonURL = "\(URL_BASE)\(URL_POKEMON)\(self.pokedexID)/"

}

func downloadPokemonDetail(completed: DownloadComplete) {

    //This is where the GET request should be



}

}

GET请求示例:

//Note that the issue is the word Alamofire that is not being recognised in my project

Alamofire.request(.GET, _pokemonURL).responseJSON { response in

    //Code for the response to go here

    print(response.result.value)

}

编辑:

我使用的是.xcworkspace文件,而不是.xcodeproj,所以这不是问题。

0 个答案:

没有答案