How would I take the output from JSON and print it to the IBOutlet's newsview? Thanks!
class ViewController: UIViewController {
@IBOutlet var newsview: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// API Endpoint:
let urlString = "[string withheld]"
let url = URL(string: urlString)
guard url != nil else {
debugPrint("URL IS nil")
return
}
let session = URLSession.shared
let dataTask = session.dataTask(with: url!) { (data, response, error) in
if error == nil && data != nil {
let decoder = JSONDecoder()
do {
let newsFeed = try decoder.decode(NewsFeed.self, from: data!)
print("Result: \(newsFeed)")
// newsview.text = NewsFeed as? String!
} catch {
debugPrint("Error in JSON Parsing!")
}
}
}
dataTask.resume()
}
override func viewDidAppear(_ animated: Bool) {
}