I got put into a project that has the following declaration:
UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("asdf") as! AsdfViewController
I've always used storyboard! to do this. It is my understanding that storyboard! will always give me UIStoryboard(name: "Main", bundle: nil). Is this a dangerous assumption to make? 
I know that you may want to use the official constructor for UIStoryboard if you wanted to reference a different storyboard file, but is it safe to abbreviate it to storyboard! if you are sure that the VC you wish to instantiate is part of Main.storyboard?
If you are calling self.storyboard from a view controller that is on another storyboard file, it will give reference to that particular storyboard; not the main storyboard. By mentioning:
UIStoryboard(name: "Main", bundle: nil)
You can make sure that you are referencing the main storyboard always.
In following situations:
using self.storyboard is enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With