数组保持返回空[swift}

时间:2016-07-01 06:48:46

标签: arrays swift

我有一个函数和数组,我尝试将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)
}

0 个答案:

没有答案