Created
March 21, 2018 13:00
-
-
Save dasmido/a278d05b6b9a6f78497e3f80ac82d0fd to your computer and use it in GitHub Desktop.
NewsApp-JSON-MainVC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MainVC.swift | |
// AlamofireJSON | |
// | |
// Created by Mohammed Jamal on 3/21/18. | |
// Copyright © 2018 Mohammed Jamal. All rights reserved. | |
// | |
import UIKit | |
import Alamofire | |
class MainVC: UIViewController { | |
var articcles = [Article]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.downloadArticlesData { | |
} | |
} | |
func downloadArticlesData(completed: @escaping DownloadComplete){ | |
// Download Forecast weather data for table view | |
Alamofire.request(BASE_URL, method: .get).responseJSON { response in | |
let result = response.result | |
if let dict = result.value as? Dictionary<String, AnyObject> { | |
if let articles = dict["articles"] as? [Dictionary<String, AnyObject>] { | |
// loop through each day to display information daily | |
for obj in articles { | |
let article = Article(articleDict: obj) | |
self.articcles.append(article) | |
print(obj) | |
} | |
//self.articcles.remove(at: 0) | |
//self.tableView.reloadData() | |
} | |
} | |
completed() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment