title: swift 3 how to get date for tomorrow and yesterday ( take care special case ) new month or new year
body: <p>I am working on data calendar for every current month 
  and I should show 3 type of calculation for ( yesterday - today - tomorrow)</p>
  
  <p>I am getting crash because of (index out of bound) for special case 
  like if today date ( 31 May 2017 )
  and I have array of May month if I try to continue my app and start calculation tomorrow I will have Error (because I should know its new month tomorrow)</p>
  
  <p>This is my code </p>
  
  <pre><code>class ViewController: UIViewController {
      var dateComponents: DateComponents!
      var TimeToday :[String] = []
      var TimeTomorrow :[String] = []
      var TimeYesterday :[String] = []
      override func viewDidLoad() {
          super.viewDidLoad()
          let dateDay = Date()
          let calendar = Calendar(identifier: .gregorian)
          dateComponents = calendar.dateComponents([.day, .month, .year], from: dateDay)
          done()
      }
      func done()  {
          //------ for tomorrow ------
          // month end day 31
          if (dateComponents.day! == 30){
              if(dateComponents.month! == 1 || dateComponents.month! == 4 || dateComponents.month! == 6 || dateComponents.month! == 7 || dateComponents.month! == 9 || dateComponents.month! == 11 ){
                  TimeTomorrow.append("\(dateComponents.month!+1)")
              }
          // month end day 31
          }else if (dateComponents.day! == 31){
              if(dateComponents.month! == 3 || dateComponents.month! == 5 || dateComponents.month! == 8 ){
                  TimeTomorrow.append("\(dateComponents.month!+1)")
              }else if(dateComponents.month! == 12){
                  TimeTomorrow.append("\(dateComponents.year!+1)")
              }
           // month end day 29
          // special case for leap year i donot know how find it
          //****************************************************
              else if (dateComponents.day! == 29){
                  if(dateComponents.month! == 2 || dateComponents.month! == 10  ){
                      TimeTomorrow.append("\(dateComponents.month!+1)")
                  }
              }
          //------ for yesterday  ------
              if (dateComponents.month! == 12 || dateComponents.month! == 10 || dateComponents.month! == 8 || dateComponents.month! == 7 || dateComponents.month! == 5 || dateComponents.month! == 2){
                  var day = dateComponents.date! - 1
                  //fatal error: unexpectedly found nil while unwrapping an Optional value
                  TimeYesterday.append("\(day)")
                  TimeYesterday.append("30 - \(dateComponents.month! - 1)")
              }else {
                  //////
              }
          }
      }
  }
  </code></pre>