EXEC_BAD_ACCESS - When trying to access a method after storyBoard Initialisation

42 views Asked by At

I am trying to write UT's for my viewController and I am initialising my viewController in the below way :

var sut: viewController!

  override func setUp() {
    super.setUp()
    let storyboard = UIStoryboard(name: "storyBoardName", bundle: nil)
    sut = storyboard.instantiateViewController(withIdentifier: "storyboard_identifier") as? viewController
    sut.loadViewIfNeeded() // Loads the view hierarchy
  }

The story board is initialised properly non-nil with the textLabels and default connections, but when I try to access any method present inside the viewControllerClass I get a EXEC_BAD_ACCESS

func testVC() {
  XCTAssertNotNil(sut) // this passes and I can see default values for attributes being assigned
  viewController.configure() // this gives EXEC_BAD_ACCESS although this is a non-private method
}
0

There are 0 answers