title: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7fff59d8dff8)
body: <p>What I'm trying to do:</p>
  
  <p>The following bit of code is for 2 buttons on a page. This page is part of an array of pages (which is stored in self.parent; it also stores the index it has in that said array in self.index).
  The 2 buttons are used to navigate forwards and backwards in this array of pages. If it tries to go forward but hits the end of the array, it should go back to the first page; Likewise for going back and hitting the beginning of the array.</p>
  
  <pre><code>@IBAction func previousButton(sender: AnyObject) {
  
      self.prev()
  }
  
  @IBAction func nextButton(sender: AnyObject) {
  
      self.next()
  }
  
  func next(){
  
      if let _parent = self.parent{
  
          if self.index != _parent.getSize()-1 {
  
              self.view.addSubview(_parent[self.index+1].view)
          }
          else{
  
              self.view.addSubview(_parent[0].view)
          }
      }
      else{
          println("This Page is not part of a List")
      }
  }
  
  func prev(){
  
      if let _parent = self.parent{
  
          if self.index != 0 {
  
              self.view.addSubview(_parent[self.index-1].view)
          }
          else{
              self.view.addSubview(_parent[_parent.getSize()-1].view)
          }
      }
      else{
          println("This Page is not part of a List")
      }
  }
  </code></pre>
  
  <p>Problem is: </p>
  
  <p><strong>EDIT:</strong> The crashes have nothing to do with the if statements and it isn't random either; It crashes when I hit the next button for the tenth time, the previous button for the tenth time <strong>(ten is the number of pages I have in my list; if I add more pages, this number changes accordingly)</strong>, and when I press prev after pressing next OR pressing next after pressing next.</p>
  
  <p><strong>I figured out the problem:</strong> I am not properly switching between pages, I am just adding one on top of the others; The crash occurs when I attempt to show a page that was already loaded (and still is somewhere beneath the stack of pages).</p>
  
  <p>Now I need to find a better way to switch between them.</p>