title: How do I refresh contents of an array from a file in Swift?
body: <p>I'm building a menu app in Swift to read the latest line from a log file. I can load the log into an array, but need to refresh it, preferably automatically. How do I get it to refresh my array? And then how do I trigger that to happen automatically?</p>
  
  <p>The app is a menu item. When you click it, a window appears with a textfield showing the last entry in the <code>logList</code> array. The <code>logList.init</code> function sits in the <code>viewDidLoad</code> function. I tried moving that to <code>viewWillLoad</code> and no change. I've tried declaring it with the <code>.init</code> function just in the class, and then re-doing it in the <code>viewDidLoad</code> with a <code>didset</code> in the original declaration that updates the textfield. Still only loads on first open.</p>
  
  <p>The variable declaration:</p>
  
  <pre><code>public var logList = LogLine.init(logLocationSTRING: " ") {
          didSet{
              latestLog = logList.logLines[(logList.logLines.count)-2]
              logLabel.stringValue = latestLog ?? "No logs found."
          }
      }
  </code></pre>
  
  <p>The initialization:</p>
  
  <pre><code>    override func viewDidLoad() {
          super.viewDidLoad()
          logList = LogLine.init(logLocationSTRING: "file:///some/log/file.log")
      }
  </code></pre>
  
  <p>The struct takes the string value of the file URL and converts it to a usable URL, loads the contents of the log into a variable, then converts those contents into an array with each line as its own item.</p>
  
  <p>I expect after closing the window and re-opening it, that it should re-call the .init function and update the contents of the <code>logList</code> variable, but it doesn't. The variable never changes unless I quit my app and re-open it.</p>