title: Change property of object in another view controller
body: <p>I have a <code>UITabBarController</code> (as initial view controller) which checks connectivity status of the device. Everytime the connectivity status changes, a checkmark in a child UITableViewController cell (<code>.accessoryType</code>) should be set (<code>.checkmark</code>) or removed (<code>.none</code>)</p>
  
  <p>Code in Tab Bar Controller:</p>
  
  <pre><code>let monitor = NWPathMonitor()
  monitor.pathUpdateHandler = { path in
      let tvc = InfoTableViewController()
      if path.status == .satisfied {
          // set .checkmark in UITableViewController
          let cell = tvc.statusOnlineCell
          print("cell :", cell)
      } else {
          // set .none in UITableViewController
      }
  }
  let queue = DispatchQueue.global(qos: .background)
  monitor.start(queue: queue)
  </code></pre>
  
  <p>Outlet in <code>UITableViewController</code>:</p>
  
  <pre><code>@IBOutlet weak var statusOnlineCell: UITableViewCell!
  </code></pre>
  
  <p>I can change the accessory type from inside the <code>UITableViewController</code> class using <code>.checkmark</code> and <code>.none</code>.</p>
  
  <pre><code>statusOnlineCell.accessoryType = .checkmark
  statusOnlineCell.accessoryType = .none
  </code></pre>
  
  <p>All fine so far!</p>
  
  <p>However as soon as I try to access the <code>UITableView.statusOnlineCell</code> from <code>UITabBar</code>, I get <code>nil</code>. Hence, I cannot change its property outside the <code>UITableViewController</code>.</p>
  
  <p>I saw 3 possible approaches:</p>
  
  <ol>
  <li><p>A global variable, which reflects the online status. I could use the <code>UITableView.viewDidAppear()</code> method to change the <code>statusOnlineCell</code> accessory type. This works, but only if <code>UITableView</code> is not shown (only if another than <code>UITableView</code> is shown). If the <code>UITableView</code> is shown and I change the connectivity status, the view is not reloaded and I didn't find any way to achieve this. Is this possible?</p></li>
  <li><p>Find a possibility to change the accessory type of <code>UITableView.statusOnlineCell</code> from the <code>UITabBarController</code>. Accessing the outlook returned in nil.  Why is that? On top, after the accessory type would have changed, I would need to reload the view (for the case that the <code>UITableView</code> was active while changing connectivity status).</p></li>
  <li><p>Is there any kind of (unknown to me) method which fires, when an object's property changed (à la <code>needReload()</code>)? This would be too good to be true I believe.</p></li>
  </ol>
  
  <p>To summarize - I need code to change the accessory type of a tableview cell, depending on the connectivity status, even whith this tableview being visible.</p>
  
  <p>I read some tutorials and stackexchange articles, Google, ... but none did the job. </p>
  
  <p>This was my top candidate, but I didn't manager to apply these examples to my situation.
  <a href="https://learnappmaking.com/pass-data-between-view-controllers-swift-how-to/#back-delegation" rel="nofollow noreferrer">https://learnappmaking.com/pass-data-between-view-controllers-swift-how-to/#back-delegation</a></p>
  
  <p>I didn't want to use notifications since not really appropriate.</p>
  
  <p>Any hint would be sufficient. Thanks in advance.</p>
  
  <p><strong>----- EDIT (14:52 UTC) -----</strong> (requested by @vadian)</p>
  
  <p>I added the (testing) code in the <code>UITabBarController</code>. The result of <code>cell</code> shows <code>nil</code>. So I cannot directly address the cell in <code>UITableView</code> from <code>UITabBarController</code>.</p>
  
  <p>The <code>UITableView</code> doesn't have any related code yet since I directly address the property <code>statusOnlineCell</code> from <code>UITabBarController</code> in order to change its accessory type.</p>
  
  <p>This approach is option 2. (of my 3 possibilities mentioned above).</p>