title: NSInvalidArgumentException : Workout_Tracker.QuickAddViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance
body: <p>I have a class MenuTabs: UIView that corresponds to MenuTabs.xib. I linked them in the identity inspector. In the view is a UICollectionView. I set the UIView as the delegate and datasource for the collection view in storyboard. I'm using the MenuTabs class in a ViewController, but I keep getting this error</p>
  
  <pre><code>'NSInvalidArgumentException', reason: '-[Workout_Tracker.QuickAddViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x7fbbe970a120'
  </code></pre>
  
  <p>Here are my MenuTabs and QuickAddViewController files</p>
  
  <pre><code>import UIKit
  
  class MenuTabs: UIView {
  
  let workoutTypes = ["", "", "", ""]
  
  let cellId = "cellId"
  
  @IBOutlet weak var contentView: UIView!
  @IBOutlet weak var collectionView: UICollectionView!
  
  override init(frame: CGRect) {
      super.init(frame: frame)
  
      collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: cellId)
  
      setup()
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  
      if self.subviews.count == 0 {
          self.setup()
      }
  }
  
  func setup() {
      Bundle.main.loadNibNamed("MenuTabs", owner: self, options: nil)
      guard let content = contentView else { return }
      contentView.frame = self.bounds
      contentView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
      addSubview(content)
  }
  }
  
  // MARK: - Delegate and Datasource methods for UICollectionView
  
  extension MenuTabs: UICollectionViewDelegate, UICollectionViewDataSource,
  UICollectionViewDelegateFlowLayout {
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return workoutTypes.count
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
  
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath)
      cell.backgroundColor = UIColor.red
  
      return cell
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>import UIKit
  
  class QuickAddViewController: UIViewController {
  
  enum MuscleGroup: String {
      case abs = "Abs"
      case arms = "Arms"
      case back = "Back"
      case calves = "Calves"
      case chest = "Chest"
      case legs = "Glutes &amp; Legs"
      case shoulders = "Shoulders"
  }
  
  enum WorkoutType: String {
      case bodyWeight = "Body Weight"
      case weightTraining = "Weight Training"
      case sportsAndRecreation = "Sports &amp; Recreation"
      case cardio = "Cardio"
  }
  
  @IBOutlet weak var workoutTypesMenu: UIView!
  
  
  let exercisesData = ExerciseDatabase()
  
  var workoutTypesDictionary = Dictionary&lt;String,Dictionary&lt;String,Array&lt;String&gt;&gt;&gt;()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      // Do any additional setup after loading the view.
      workoutTypesDictionary = self.exercisesData.exercisesByWorkoutType
  
      tabBarController?.tabBar.isTranslucent = false
  
      // Load workoutTypesMenu View
      if let wtMenu = Bundle.main.loadNibNamed("MenuTabs", owner: self, options: nil)?.first as! MenuTabs? {
          workoutTypesMenu.addSubview(wtMenu)
  
      }
  }
  
  // MARK: - Get data from ExerciseDatabase.swift
  
  // Get the workout types
  func getWorkoutTypes() -&gt; [String] {
      var workoutTypesArray : [String] = []
      for workoutType in workoutTypesDictionary.keys {
          workoutTypesArray.append(workoutType)
      }
  
      return workoutTypesArray
  }
  
  // Get the list of muscles or options
  func getMusclesOrOptions(for workoutType: String) -&gt; [String] {
      var musclesOrOptionsArray : [String] = []
  
      let musclesOrOptions = workoutTypesDictionary[workoutType]!.keys
  
      for muscleOrOption in musclesOrOptions {
          musclesOrOptionsArray.append(muscleOrOption)
      }
  
      return musclesOrOptionsArray
  }
  
  // Get the list of exercises
  func getExercisesArray(for workoutType: String, for muscleOrOption: String) -&gt; [String] {
      var exercisesArray : [String] = []
  
      exercisesArray = workoutTypesDictionary[workoutType]![muscleOrOption]!
  
      return exercisesArray
  }
  
  // Get the selected exercise
  func getSelectedExercise(in workoutType: String, for muscleOrOption: String, at index: Int) -&gt; String {
      var selectedExercise : String = ""
  
      selectedExercise = workoutTypesDictionary[workoutType]![muscleOrOption]![index]
  
      return selectedExercise
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  // MARK: - WorkoutTypesBar and Muscles and Options Bar
  // Set up the WorkoutTypes bar and the muscles and option types bar
  </code></pre>
  
  <p>}</p>