title: Fatal Error: Index out of Range / UIPickerView /Array/ Swift
body: <p>My UIPickerView with four components gives me this back when I'm trying to build it. What should I do I mean I made the number Of Rows one Point bigger because in Swift numbers start at 0 but nothing worked....
  What is the problem?</p>
  <pre><code>let componentOne = [1...1000]
      let componentTwo = [1...59]
      let componentThree = [1...59]
      let componentFour = [1...10]
      
      func numberOfComponents(in pickerView: UIPickerView) -&gt; Int {
          return 4
      }
      func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
          if component == 0 {
              return 1000
          }
          if component == 1 {
              return 59
          }
          if component == 2 {
              return 59
          }
          if component == 3 {
              return 10
          }
          return component
      }
          
      func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String? {
          if component == 0 {
              _ = componentOne[row]
              return &quot;\(1000)&quot;
              }
              if component == 1 {
                  _ = componentTwo[row]
                  return &quot;\(59)&quot;
                  }
                  if component == 2 {
                      _ = componentThree[row]
                      return &quot;\(59)&quot;
                      }
                      if component == 3 {
                          _ = componentFour[row]
                          return &quot;\(10)&quot;
                          }
          return nil
                      }
      
  </code></pre>