title: Error: index beyond bounds
body: <p>I have been getting the error of index beyond bounds.</p>
  
  <p>I have been dealing with ZLSwipeableView Swift Version.</p>
  
  <p>The code</p>
  
  <pre><code> import UIKit
  
     class SwipeableViewController: UIViewController  {
  
           var swipeAbleView : ZLSwipeableView!
  
                  override func viewDidLayoutSubviews() {
                      super.viewDidLayoutSubviews()
                      swipeAbleView.nextView = {
                       return self.nextCardView()
                      }
                  }
  
  // This is the colors array
                  var colors : NSArray = NSArray(array: [UIColor.orangeColor() , UIColor.blueColor() , UIColor.greenColor() , UIColor.blackColor() , UIColor.brownColor() , UIColor.magentaColor()])
  
               var v : UIView!
  
               var cardsCount = 6
               var cardsIndex = 0
  
                override func viewDidLoad() {
                      super.viewDidLoad()
  
                      // Do any additional setup after loading the view.
  
                      view.backgroundColor = UIColor.whiteColor()
                      view.clipsToBounds = true
  
                      swipeAbleView = ZLSwipeableView()
                      swipeAbleView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
                      self.swipeAbleView.alpha = 0.0
  
                      UIView.animateWithDuration (0.25, delay: 0.35, options: UIViewAnimationOptions.CurveLinear ,animations: {
                          self.swipeAbleView.alpha = 1.0
                          }, completion:nil)
                      self.view.addSubview(swipeAbleView)
  
  
                      self.swipeAbleView.discardViews()
                      self.swipeAbleView.loadViews()
                  }
  
                  func nextCardView() -&gt; UIView {
  
                      if cardsIndex &lt; cardsCount {
  
                      cardsIndex += 1
                      }
  
                      let cardView = CardView(frame: self.swipeAbleView.bounds)
  // The error occurs here and the app crashes
                      cardView.backgroundColor = colors[cardsIndex] as? UIColor
  
                      return cardView
  
                  }
              }
  </code></pre>
  
  <p>The error occurs when I define the color for the cardView. </p>
  
  <p>The application crashes I get the error.</p>