我有一个函数和数组,我尝试将xml数据保存到数组中,但是当我打印出来时它返回空集。为什么?
func populateCountries() {
Alamofire.request(.POST, "https://api.jocom.com.my/feed", parameters: ["req" : "country"])
.responseData { response in
let getCountriesXML = SWXMLHash.parse(response.data!)
for elem in getCountriesXML["rss"]["channel"]["item"] {
//var countriesArray = [String]() which i declare outside of the function.
self.countriesArray.append(elem["name"].element!.text!)
}
}
print(self.countriesArray)
print(self.countriesArray.count)
}