title: iOS Swift 3 select multiple rows in tableView initially at creation
body: <p>I want to select some rows when my tableView is loaded. Therefore I use this code inside my cellForRowAt:</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      let cell = tableView.dequeueReusableCell(withIdentifier: "suggest", for: indexPath) as! groupViewControllerCell
      let item = self.feed!.items[indexPath.row]
      cell.title.text = item.name
      cell.setSelected(true, animated: true)
      return cell
  }
  </code></pre>
  
  <p>The problem is, it selects all rows, but only for the blink of an eye. It quickly is deselected. My viewDidAppear has the following code:</p>
  
  <pre><code>override func viewDidAppear(_ animated: Bool) {
  tableView.allowsMultipleSelectionDuringEditing = true
  tableView.allowsSelection = true
  self.tableView.setEditing(true, animated: false)
  self.loadAllGroups()
  </code></pre>
  
  <p>loadAllGroups gets all the data from the server and reloads the tableView afterwards.</p>
  
  <pre><code>func loadAllGroups()
  {
      if let url = URL(string: urlString) {
          self.updateGroupFeed(url, completion: { [unowned self] (feed) -&gt; Void in
              self.feed = feed
          })
      }
  }
  </code></pre>
  
  <p>updateGroupFeed looks like the following snippet:</p>
  
  <pre><code>func updateGroupFeed(_ url: URL, completion: @escaping (_ feed: GroupFeed?) -&gt; Void) {
  
      **headers for alamofire request**
  
      Alamofire.request(url, method: .get, encoding: JSONEncoding.default, headers: headers)
          .responseJSON { [unowned self] response in
              guard let responseError = response.result.error else {
                  let feed = GroupFeed(data: response.data!, sourceURL: url)
                  OperationQueue.main.addOperation({ [unowned self] () -&gt; Void in
                  })
                  completion(feed)
                  return
              }
      }
  }
  </code></pre>
  
  <p><strong>Now my question is</strong>: How can I select the cells correctly? I use it to cache the users last selection. </p>