title: App freezes when a tableViewController is opened
body: <p>First want to know how can I debug where the issue is, what is stalling the main thread indefinitely. I read somewhere that as soon as my app freezes, i should pause it and see the threads and i'll able to see what is taking up so long. I did that but I cant identify the cause.
  <a href="https://i.stack.imgur.com/J0Yhq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0Yhq.png" alt="Screenshot of threads in frozen app state"></a></p>
  
  <p>Secondly, I should also mention my scenario because the freeze is always reproducible. I open a <code>tableViewController</code>on tap of a <code>UILabel</code> (through <code>TapGestureRecongniser</code>). The user can select multiple cells in the <code>tableViewController</code> and the <code>UILabel</code> reflects the values, user selected in <code>tableViewController</code>. I have a central ContentManager which handles the content of the app. The <code>tableViewController</code> changes a list in the <code>ContentManager</code> and <code>UILabel</code> fetches that list to update it self. Everything is working fine till here. If I open the <code>TableViewController</code> again, the app freezes. This only happens if the user has changed the selected cells. If user opens <code>tableViewController</code> but does not change any cell's selected state and presses back, app does not freezes on opening it again. This is code of my <code>tableViewController</code></p>
  
  <pre><code>import UIKit
  import SwiftEventBus
  
  class InterestsTableViewController: UITableViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          title = "Select Your Interests"
  
          navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Select", style: .Plain, target: self, action: #selector(addTapped))
          navigationItem.rightBarButtonItem?.enabled = false
  
          self.clearsSelectionOnViewWillAppear = false
          setPreSelectedCells()
      }
  
      func setPreSelectedCells() {
          var interestList = ContentManager.shared.getInterests()!
  
          if interestList.count &gt; 0 {
  
              for i in 0..&lt;interestList.endIndex {
  
                  let interest  = interestList[i]
                  let indexPath = NSIndexPath(forRow: 0, inSection: i)
  
                  if interest.isSelected {
  
                      tableView.selectRowAtIndexPath(indexPath, animated: false, scrollPosition: UITableViewScrollPosition.None)
                      self.tableView(self.tableView, didSelectRowAtIndexPath: indexPath);
                  } else {
  
                      tableView.deselectRowAtIndexPath(indexPath, animated: false)
                      self.tableView(self.tableView, didDeselectRowAtIndexPath: indexPath);
                  }
              }
          }
      }
  
      func addTapped() {
          print("interests selected")
          print(tableView.indexPathsForSelectedRows?.count)
  
          if let indexPaths = tableView.indexPathsForSelectedRows {
  
              var selectedInterests : [String] = []
              for indexPath in indexPaths {
                  selectedInterests.append(ContentManager.shared.getInterests()![indexPath.section].id)
              }
  
              if selectedInterests.count &gt; 0 {
                  ApiCallsManager.updateInterests(selectedInterests)
                  navigationController?.popViewControllerAnimated(true)
              }
          }
      }
  
      // MARK: - Table view data source
      override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
  
          if ContentManager.shared.getInterests() != nil {
              return ContentManager.shared.getInterests()!.count
          } else {
              return 0
          }
      }
  
      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return 1
      }
  
      override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -&gt; CGFloat {
          return 10.0
      }
  
      override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView {
  
          let headerView: UIView = UIView()
          headerView.backgroundColor = UIColor.clearColor()
          return headerView
      }
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
          let cell = tableView.dequeueReusableCellWithIdentifier("InterestsTableViewCell", forIndexPath: indexPath) as! InterestsTableViewCell
  
          let interest = ContentManager.shared.getInterests()![indexPath.section]
          cell.interestLabel.text = interest.getCategory()
          cell.picture.kf_setImageWithURL(NSURL(string: interest.picture)!)
  
          if cell.selected {
              cell.filter.alpha = 0.85
          } else {
              cell.filter.alpha = 0.3
          }
  
          return cell
      }
  
      override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
          if let cell = tableView.cellForRowAtIndexPath(indexPath) as? InterestsTableViewCell {
                      cell.filter.alpha = 0.85
  
              if let count = tableView.indexPathsForSelectedRows?.count {
                  navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Select (\(count))", style: .Plain, target:    self, action: #selector(addTapped))
          } else {
                  navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Select", style: .Plain, target:    self, action: #selector(addTapped))
                  navigationItem.rightBarButtonItem?.enabled = false
              }
          }
      }
  
      override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
  
          if let cell = tableView.cellForRowAtIndexPath(indexPath) as? InterestsTableViewCell  {
              cell.filter.alpha = 0.3
  
              if let count = tableView.indexPathsForSelectedRows?.count {
                  navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Select (\(count))", style: .Plain, target:    self, action: #selector(addTapped))
              } else {
                  navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Select", style: .Plain, target:    self, action: #selector(addTapped))
                  navigationItem.rightBarButtonItem?.enabled = false
              }
          }
      }
  }
  </code></pre>
  
  <p>Thanks.</p>