SwiftGen / SwiftGen

The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!
MIT License
9.25k stars 733 forks source link

Support `performSegueWithIdentifier:sender` with UIStoryboard.Segue types #37

Closed jakecraige closed 8 years ago

jakecraige commented 8 years ago

it would be great if I could call performSegueWithIdentifier with the segue enum type instead of having to call rawValue.

// this
performSegueWithIdentifier(UIStoryboard.Segue.Main.ViewAnnouncement, sender: nil)

// instead of
performSegueWithIdentifier(UIStoryboard.Segue.Main.ViewAnnouncement.rawValue, sender: nil)
AliSoftware commented 8 years ago

Good suggestion!

I'm focused on #24 which will be a big refactor that would allow people to use templates for generating the code. This will make it way easier to fix missing stuff like this in the generated code.

You could either make a PR now if this need is urgent, or wait until I introduce Stencil and the use of templates to fix the template (which would probably be way easier, but will need #24 to be done first)

AliSoftware commented 8 years ago

Now that #24 is fixed and that SwiftGen now uses templates, it should be very easy to make a PR to add support for this!

Probably by making the same trick with the Segue enum that is done with Scene enum, by making it conform to a StoryboardSegue protocol and provide an extension StoryboardSegue where Self.RawValue == String so that those segues can have the implementation for performSegueWithIdentifier(…) method for free.