append json values to a global array using Alamofire and SwiftyJson


Ask A Question





Login To post a question
var imgURLArray = [String]()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    myTableView.delegate = self
    myTableView.dataSource = self

    `enter code here`// Alamofire
        Alamofire.request("https://api.instagram.com/v1/users/self/media/recent/?access_token=####&count=10").responseJSON { (response) in
            if let value = response.result.value {

                let json = JSON(value)

                for i in 1...9 {
                    if let imageURL = json["data"][i]["images"]["standard_resolution"]["url"].string {
                        //print(imageURL)
                        //print("*******")
                        self.imgURLArray.append(imageURL)



                    } else {print("no way")}

                }
                print(self.imgURLArray)
            }
            //print(self.imageURLArray)
        }


    }

when i print imgURLArray it is empty
i tried dispatchQueue and still not working
i tried passing it to tableview and reload it and still not working

For more info please click herehttps://stackoverflow.com/q/51863816



Have a question or need a custom quote?
info@smartinfocare.com