title: what is the function of NSObject in StoryBoard / Interface Builder?
body: <p>I am currently following a video tutorial course about test driven development of iOS in Swift, but when testing Table View in View Controller, I get stuck, since I don't understand why we need NSObject in Interface builder like the picture below:</p>
  
  <p>Movie Library Data Service is inheritted NSObject class:</p>
  
  <p><a href="https://i.stack.imgur.com/LavBO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LavBO.png" alt="enter image description here"></a></p>
  
  <p>the class of <code>MovieLibraryDataService</code> is like this:</p>
  
  <pre><code>import UIKit
  
  class MovieLibraryDataService: NSObject, UITableViewDataSource, UITableViewDelegate {
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return 0
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          return UITableViewCell()
      }
  
  
  }
  </code></pre>
  
  <p>and the <code>MovieLibraryDataService</code> class will be used in XCTestCase is like this :</p>
  
  <pre><code>@testable import FilmFest
  class LibraryViewControllerTests: XCTestCase {
  
      var sut: LibraryViewController!
  
      override func setUp() {
          super.setUp()
          // Put setup code here. This method is called before the invocation of each test method in the class.
          sut = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LibraryViewControllerID") as! LibraryViewController
          _ = sut.view
      }
  
      override func tearDown() {
          // Put teardown code here. This method is called after the invocation of each test method in the class.
          super.tearDown()
      }
  
      // MARK: Nil Checks
      func testLibraryVC_TableViewShouldNotBeNil() {
          XCTAssertNotNil(sut.libraryTableView)
      }
  
      // MARK: Data Source
      func testDataSource_ViewDidLoad_SetsTableViewDataSource() {
          XCTAssertNotNil(sut.libraryTableView.dataSource)
          XCTAssertTrue(sut.libraryTableView.dataSource is MovieLibraryDataService)
      }
  
      // MARK: Delegate
      func testDelegate_ViewDidLoad_SetsTableViewDelegate() {
          XCTAssertNotNil(sut.libraryTableView.delegate)
          XCTAssertTrue(sut.libraryTableView.delegate is MovieLibraryDataService)
      }
  
      // MARK: Data Service Assumptions
      func testDataService_ViewDidLoad_SingleDataServiceObject() {
          XCTAssertEqual(sut.libraryTableView.dataSource as! MovieLibraryDataService, sut.libraryTableView.delegate as! MovieLibraryDataService)
      }
  
  
  
  }
  </code></pre>
  
  <p>and the definition of LibraryViewController: </p>
  
  <pre><code>import UIKit
  
  class LibraryViewController: UIViewController {
  
      @IBOutlet weak var libraryTableView: UITableView!
      @IBOutlet var dataService: MovieLibraryDataService!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          self.libraryTableView.dataSource = dataService
          self.libraryTableView.delegate = dataService
      }
  
  
  }
  </code></pre>
  
  <p>I really don't understand why I need to make that <code>MovieLibraryDataService</code> class</p>
  
  <p>I usually use:</p>
  
  <pre><code>self.libraryTableView.dataSource = self
  self.libraryTableView.delegate = self
  </code></pre>
  
  <p>but why do I need to write :</p>
  
  <pre><code>self.libraryTableView.dataSource = dataService
  self.libraryTableView.delegate = dataService
  </code></pre>