title: Array index out of range on refresh
body: <p>I have a <code>Posts</code> class that I am querying in a <code>UITableViewController</code> using <code>Parse</code> as my backend. </p>
  
  <p>In my <code>viewDidAppear</code> I call my <code>loadData()</code> function. And then I have a <code>var refresher = UIRefreshControl()</code> that is responsible for my <code>refresh()</code> function. </p>
  
  <p>After a few time reloading the data I get a a <code>fatal error: Array index out of range</code> and the following line of code highlighted which is in my <code>cellForRowAtIndexPath</code>. </p>
  
  <p><img src="https://i.stack.imgur.com/vLGo9.png" alt="enter image description here"></p>
  
  <p>What was interesting is when I printed out what was in my 
  index path using <code>println(drive)</code>, all the posts were there. But then there were instances where some posts appeared twice then the app would crash. </p>
  
  <pre><code>timelineData.removeAll(keepCapacity: false)
  </code></pre>
  
  <p>I thought that having this should clear everything so I am not sure why this is happening. </p>
  
  <p>Here is my code for my refresh function. </p>
  
  <pre><code>func refresh()
  {
  
      println("refresh table from pull")
  
      timelineData.removeAll(keepCapacity: false)
  
      var findItemData:PFQuery = PFQuery(className:"Posts")
  
      findItemData.addDescendingOrder("createdAt")
  
      findItemData.findObjectsInBackgroundWithBlock{
          (objects:[AnyObject]? , error:NSError?) -&gt; Void in
          if error == nil
          {
              self.timelineData = objects as! [PFObject]
              self.newsFeedTableView.reloadData()
  
          }
  
      }
      self.refresher.endRefreshing()
  
  
  }
  </code></pre>
  
  <p>I tried using Parse's <code>query.cachePolicy</code> but that didn't matter because the crash kept happening. <a href="https://parse.com/docs/ios/guide#queries-querying-the-local-datastore" rel="nofollow noreferrer">https://parse.com/docs/ios/guide#queries-querying-the-local-datastore</a></p>
  
  <p>I also thought it was because I have  <code>Parse.enableLocalDatastore()</code> but still no luck. </p>
  
  <p>I do call my other function <code>loadData</code> in my <code>viewDidAppear</code> as mentioned earlier, not sure if this might be the problem, but I don't know how to check for data when there is an update. Still not sure if this is the source of the problem. </p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I have attached my timelinedata count in several functions. Second image is when I print the count in my <code>cellForRowIndexPath</code>
     <img src="https://i.stack.imgur.com/AYAPp.png" alt="enter image description here"><img src="https://i.stack.imgur.com/9hE77.png" alt="enter image description here"></p>