title: How to add an item from another class? Swift
body: <p>I’m doing a news management exercise. I have some classes:</p>
  <ul>
  <li>Author</li>
  <li>News (father)</li>
  <li>NewsVideo (son) (this class has the same properties as the father, plus it has two properties)</li>
  <li>NewsManagement</li>
  </ul>
  <p>From the NewsManagement class, I have to create a function that inserts a news.
  I have already created an empty array of type News.
  NewsManagement class has only one property, an empty News array.</p>
  <pre><code>var newsCollection: [News] = []
  class NewsManagement {
      
      var news: [News] = []
      
      init(news: [News]) {
          self.news = news
      }
  
  func insertNews(title: String, text: String, date: Int, author: Autore, urlVideo: String?, videoLength: Double?) -&gt; String? {
          
          //these are the properties of the newsVideo class
          guard let urlVideo = urlVideo, let videoLength = videoLength else {
              return nil
          }
          self.news.append(News.init(title: String, text: String, date: Int, author: Author))
          return &quot;news addition”
      }
  }
  var manager = NewsManagement.init(news: newsCollection)
  manager.insertNews(title: &quot;prima prova&quot;, text: &quot;spero funzioni&quot;, date: 13, author: authors[3], urlVideo: &quot;www.prova.it&quot;, videoLength: 4.5)
  //authors is an array of instance of class Author
  
  </code></pre>
  <p>Unfortunately, it’s not working.
  Do you know where the error is?
  Or do you know another way?
  I’ve been trying solutions for too long, but none of them work</p>
  <p>Thank you!</p>