I am trying to receive data from a JSON URL and then put that data into a UITableView - I am currently trying to put it into a UIlabel for simplicity but will try and figure how to use a table later!
I am using the latest version of Swift and xCode, SwiftyJSON and Alamofire.
There is no errors in my code, yet the thing that I want to happen is not happening. My UILabel is hooked up fine as well!
Here is my code - (For some reason when I paste my code onto here some of the code is not listed as code - it is in my code though so that is not the issue!!!)
import UIKit
import Alamofire
class ViewController: UIViewController {
@IBOutlet weak var dataContainer: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let url = "https://opendata.gov.je/dataset/bdae149d-ff02-443a-b5ed-446a206e74f7/resource/042ea501-a4eb-48c1-9a23-9f01084d72e6/download/stats-from-govmetric.json.txt"
Alamofire.request(.GET, url).validate().responseJSON { response in
switch response.result {
case .Success(let data):
let json = JSON(data)
let name = json["name"].stringValue
self.dataContainer.text = data as? String
print(response.request)
print(response.response)
print(response.result)
print(name)
case .Failure(let error):
print("Request failed with error: \(error)")
}
}
}
}