Good afternoon!
I'm relatively new to Swift, though I think I've managed to wrap my head around most of it, however I'm having difficulties setting a segue's destinationViewController indirectly.
I understand that destinationViewController accepts AnyObject? but how do I go about returning the class as a function's return value directly to destinationViewController? Something like:
override func prepareForSegue( segue: UIStoryboardSegue, sender: AnyObject? ) {
if( segue.identifier == "nextView" ) {
let nextScene = segue.destinationViewController as? getNextView()
// ...blah blah blah...
}
}
Where getNextView() is overridden by a subclass whose sole purpose is to return a reference to the destinationViewController:
override func getNextView -> AnyObject! {
return SomeClassBasedOnUIViewController
}
XCode isn't happy I'm employing "consecutive statements" on one line in my prepareForSegue() and I'm at a loss how to resolve it so any help would be greatly appreciated!
Thanks!
EDIT:
Sorry about that, but getNextView() doesn't actually return an Optional. Just picked up on that and amended the question. The issue persists regardless, though.
What you're trying to do is illogical. This is a compile time indication of the class or protocol to which the reference must conform. Trying to get this reference at runtime won't help you. Instead you should be checking for conformance to a static protocol and then dispatching calls based on that protocol to an unknown implementation class.