如何从阿拉莫火中返回价值
class API { let apiEndPoint = "endpoint" let apiUrl:String! let consumerKey:String! let consumerSecret:String! var returnData = [:] init(){ self.apiUrl = "https://myurl.com/" self.consumerKey = "my consumer key" self.consumerSecret = "my consumer secret" } func getOrders() -> NSDictionary{ return makeCall("orders") } func makeCall(section:String) -> NSDictionary{ let params = ["consumer_key":"key", "consumer_secret":"secret"] Alamofire.request(.GET, "\(self.apiUrl)/\(self.apiEndPoint + section)", parameters: params) .authenticate(user: self.consumerKey, password: self.consumerSecret) .responseJSON { (request, response, data, error) -> Void in println("error \(request)") self.returnData = data! as NSDictionary } return self.returnData }}
UITableViewController
returnData
data
var api = API()api.getOrders()println(api.returnData) // returnData is empty
茅侃侃
相关分类