mluton / EmbeddedSwapping

Demonstration of how to make a custom container view controller manage multiple child view controllers using storyboards.
MIT License
208 stars 30 forks source link

Crash when trying to make second view controller load first #4

Closed rtamesis closed 11 years ago

rtamesis commented 11 years ago

Sorry to bug you again, but I was trying to see if I could load the second view controller first by just simply changing the line self.currentSegueIdentifier = SegueIdentifierFirst in the ContainerViewController's viewDidLoad method to self.currentSegueIdentifier = SegueIdentifierSecond instead. Doing so, however, always results in a crash. I get this error message in the console:

2013-06-01 12:21:14.470 CustomContainers5[5485:c07] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array' *\ First throw call stack: (0x159b012 0x12a8e7e 0x1550b44 0x2eb2 0x634b87 0x2cedd2 0x2597 0x2ce1c7 0x2ce232 0x758ea1 0x634b99 0x634c14 0x2ce16c 0x2ce232 0x21d3d5 0x21d76f 0x21d905 0x226917 0x1ea96c 0x1eb94b 0x1fccb5 0x1fdbeb 0x1ef698 0x25fddf9 0x25fdad0 0x1510bf5 0x1510962 0x1541bb6 0x1540f44 0x1540e1b 0x1eb17a 0x1ecffc 0x21dd 0x2105) libc++abi.dylib: terminate called throwing an exception (lldb)

I'd like to be able to have the ViewController class tell the ContainerViewController which of the two view controllers to display initially in the app that I'm building. Any suggestions or workarounds? Thanks!

rtamesis commented 11 years ago

I think I solved the problem by making these changes to the prepareForSegue in the ContainerViewController: