Crash on pushViewController with [NSNull set]: unrecognized selector

I have an app where I just created a new, working viewController in a separate project. I copy/pasted the code and xibs (several subviews) into the new project. All compiles fine. Relevant code:

`let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

//let nextViewController = storyBoard.instantiateViewController(withIdentifier: "NewManualGlyphVC") as! NewManualPickGlyphViewController //old Selector

let nextViewController = storyBoard.instantiateViewController(withIdentifier: "GlyphSelectVC") as! GlyphSelectViewController //new Selector

self.navigationController?.pushViewController(nextViewController, animated: true) `

The commented out line was the vector to the old, working VC. The new code crashes inside the push. the new nextViewController is fine, the Xcode quick view shows the expected view, and the navController is also just fine. The reported error is:

`myApp[42661:963870] -[NSNull set]: unrecognized selector sent to instance 0x7ff86599bc30

` Environment is Xcode 14.3.1 compiled to ios13, target device iOS 16. Any thoughts? Thanks!!

Replies

My guess is that you have an invalid outlet connection in the storyboard (or a XIB, if you're using those too). The NSNull object may be what's being set as the linked object when the outlet is broken.

When you changed the view controller name from NewManualPickGlyphViewController, to GlyphSelectViewController, did you remember to update the class name of the corresponding view controller entities in your storyboard/XIBs?

The old VCs and IB Xibs are still in place. In transitioning to the new VC, I just pasted the new classes (all with different names) into the project. I rechecked all the outlets in the IB Connections pane and they all go to the correct place.

I appreciate the thought though. LLDB does not catch the NSNull call so I can’t see where it’s coming from.

might you have any other thoughts I can track down. This one stumps me.

The old VCs and IB Xibs are still in place.

I'm not sure what this means in terms of the new project. Did you actually check that all of your class names are correct in the Identity inspector for the various resource files?

You could also do a project-wide search for the old names, then a search for the new names, and make sure they're all one thing or the other. (Xcode's project-wide search will search in storyboard and XIB files.)

  • Your comment about the system initially stuffing [NSNull] as arguments got me exploring further. The crash is actually not in the PushVC, but rather in the units of one of programmatically defined (not IB) subviews in the new GlyphSelectViewController. I’ve been driving for the past two hr, and just got back to my laptop. Hopefully I can sort this out. It’s in a subview of a sub view…..

  • Sorry for the delay.

    So, your last comment prompted me to explore further. The crash is not actually in pushViewController, but in the init of a subview of a subview in the new VC. These subviews are all programmatically defined and so have no outlets to connect to IB.

    Oddly, the crash occurs between the viewWillAppear() of the sub-subView and its viewDidAppear()! At end of viewWillAppear, the subview (a collectionView) is entirely populated. No viewIsAppearing is available.

  • OK, so if you haven't found the problem in the above scenario, maybe you can restate your original question in terms of what's actually going wrong?

Add a Comment