title: Swift - Extra argument 'image' in call
body: <p>I am trying to turn the following which works</p>
  
  <pre><code>tempNews.append(News(title: $0.title))
  </code></pre>
  
  <p>into</p>
  
  <pre><code>tempNews.append(News(title: $0.title, image: $0.image))
  </code></pre>
  
  <p>However when I type it I get the following error <code>Extra argument 'image' in call</code> now the JSON file does have image so I know its not the JSON return that is causing this error. So It must be something else either in </p>
  
  <pre><code>struct NewsData: Decodable{
      let news: [articalData]
  }
  
  struct articalData: Decodable{
      let title: String
      let image: String
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>import Foundation
  //import UIKit
  
  class News {
    //  var image: UIImage
      var title: String
      var image: String
  
      init(title: String) {
          self.image = image
          self.title = title
      }
  }
  </code></pre>
  
  <p><strong>Here is the full view controller script</strong></p>
  
  <pre><code>    //
  //  NewsViewController.swift
  //  DRN1
  //
  //  Created by Russell Harrower on 26/11/19.
  //  Copyright © 2019 Russell Harrower. All rights reserved.
  //
  
  import UIKit
  import Foundation
  
  
  struct NewsData: Decodable{
      let news: [articalData]
  }
  
  struct articalData: Decodable{
      let title: String
      let image: String
  }
  
  class NewsViewController: UIViewController {
      @IBOutlet weak var tableView: UITableView!
  
  
      var news: [News] = []
  
      override func viewDidLoad() {
        super.viewDidLoad()
  
          tableView.delegate = self
          tableView.dataSource = self
      }
  
      override func viewDidAppear(_ animated: Bool) {
         self.tabBarController?.navigationItem.title = "News"
  
           self.newsfetch { [weak self] news in
                      guard let news = news else { return }
                      self?.news = news
              DispatchQueue.main.async {
                      self?.tableView.reloadData()
              }
              }
       }
  
  
      func newsfetch(_ completionHandler:  @escaping ([News]?)-&gt;Void){
          let jsonURLString = "https://api.drn1.com.au/api-access/news"
          guard let feedurl = URL(string: jsonURLString) else {  return }
  
          URLSession.shared.dataTask(with: feedurl){ (data,response,err)
              in
              guard let news = data else { return }
              do {
                  let newsdata = try JSONDecoder().decode(NewsData.self, from: news)
                  var tempNews: [News] = []
                  newsdata.news.forEach(){
                      var strUrl = $0.image
                      strUrl = strUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
  
                      tempNews.append(News(title: $0.title, image: strUrl))
                  }
                  completionHandler(tempNews)
              } catch let jsonErr {
                  print("error json ", jsonErr)
                  completionHandler(nil)
              }
          }.resume()
  
      }
  }
  
  
  extension NewsViewController: UITableViewDataSource, UITableViewDelegate {
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return news.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let newsa = news[indexPath.row]
  
          let cell = tableView.dequeueReusableCell(withIdentifier: "NewsCell") as! NewsCell
          cell.setNews(news: newsa)
          return cell
      }
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          performSegue(withIdentifier: "shownewsarticle", sender: self)
      }
  
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          if let destination = segue.destination as?  NewsArticleViewController{
              destination.article = news[(tableView.indexPathForSelectedRow?.row)!]
              tableView.deselectRow(at: tableView.indexPathForSelectedRow!, animated: true)
          }
  
      }
  
  
  }
  </code></pre>
  
  <p>My first plan is to just get it to not throw that error, and once I have that working i'll use kingfisher to load the remote image.</p>