My question is pretty simple: On the iPhone/iPad simulator, when you push a nil view Controller, you are greeted by the gracious message
Application tried to push a nil view controller on target
after which the app continues execution as if nothing happened. This is exactly the type of behavior I want of the app (I have a factory method, which, if encounters an incorrect request for the creation of an instance, returns nil).
However I have doubts as to whether this will fly as is on the real iOS device. Since I cannot deploy in this early stage of development, I would like to know whether this action would result in a crash, or it will graciously do nothing (as expected). Furthermore, if it works on the iOS, will I get slapped by Apple in the review process for doing 'bad things'?
When it comes to Cocoa Touch methods, you should never pass a nil parameter unless the reference documentation explicitly states that a nil parameter is valid. If the documentation is ambiguous, don't rely on empirical testing (in the simulator or otherwise) to decide that it's safe. Apple may release a future OS update that suddenly causes your app to start crashing for your existing users. Then they'll give your app bad reviews for a week or two while Apple reviews your hotfix. It's just not worth the risk.
The documentation for pushViewController:animated:
doesn't specify how it will behave if given a nil parameter, so play it safe and test for nil in your code.