Closed CallumOz closed 9 years ago
@CallumOz does it solve #27 ? I it is for some cases but I think (not sure) some are still not addressed - the case when the very same viewviewcotrller class is used twice in the same storyboard, with different identifiers. Correct me if I'm wrong
It does fix the problem in #27 even though I took a totally different approach. Since each ViewController is created using a function with the same name as the storyboard identifier, which is already unique per storyboard.
Would you mind update README according to this changes ?
I have already updated the README.
oh sorry, missed that ;) the PR looks really nice. good work!
@CallumOz there is a problem with Example project, can you please look at it and PR the fix asap?
Somehow I missed this.
It seems that swift doesn't like functions with the same names as classes.
My storyboard identifiers are generally like: MainVC
or LoginVC
An easy fix is to change:
static func MainViewController() -> MainViewController! {
return self.storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController
}
To:
static func instantiateMainViewController() -> MainViewController! {
return self.storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController
}
If you agree with my fix, I'll add it straight away.
We'll change that back after they fix it in Swift. The other way is use camel case for function name but nobody will find it then.
I think this method is probably better anyway, this way all functions for creating a ViewController start with "instantiate".
Hi,
I modified quite a few things, the main reason was to be able to use the same ViewController class multiple times in different storyboards each with a different Storyboard ID. This was impossible before because you would end up adding an extension twice to the same class.
Now because the storyboards are structs, it means that I was able to specialise instantiateInitialViewController method so that the return type is the same as the type of the ViewController.
To instantiate a Viewcontroller with id "ListVC" in storyboard Main, you do:
If you have any questions or remarks, my ears are open.