Skip to content
This repository was archived by the owner on Sep 6, 2019. It is now read-only.
This repository was archived by the owner on Sep 6, 2019. It is now read-only.

Conflict when Storyboard filename matches UIViewController subclass name #129

Description

@yoiang

A project I am working on correlates our Storyboard file's names with the UIViewController subclass that is it's initial view controller. The result is a Storyboards.* struct that conflicts in naming with the view controller type itself:

...
    struct ExampleViewController: Storyboard {

        static let identifier = "ExampleViewController"

        static var storyboard: UIStoryboard {
            return UIStoryboard(name: self.identifier, bundle: nil)
        }

        static func instantiateExampleViewController() -> ExampleViewController {
            return self.storyboard.instantiateExampleViewController() as! ExampleViewController
        }

        static func instantiateViewController(withIdentifier identifier: String) -> UIViewController {
            return self.storyboard.instantiateViewController(withIdentifier: identifier)
        }

        static func instantiateViewController<T: UIViewController>(ofType type: T.Type) -> T? where T: IdentifiableProtocol {
            return self.storyboard.instantiateViewController(ofType: type)
        }
    }
...

I appreciate the brevity of the struct's name and appending something like "File" clutters that. On the other hand it is more explicit: these are mappings to files as much as we'd love to abstract them away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions