Skip to content

Instantly share code, notes, and snippets.

@eofster
Created December 1, 2015 15:28
Show Gist options
  • Select an option

  • Save eofster/3f8a5bff2796f165699a to your computer and use it in GitHub Desktop.

Select an option

Save eofster/3f8a5bff2796f165699a to your computer and use it in GitHub Desktop.
Wireframe and view controller factory
class Wireframe {
let navigationController: UINavigationController
let viewControllerFactory: ViewControllerFactory
init(navigationController: UINavigationController, viewControllerFactory: ViewControllerFactory) {
self.navigationController = navigationController
self.viewControllerFactory = viewControllerFactory
}
func presentPhotoDetailsWithPhoto(photo: Photo) {
let vc = viewControllerFactory.createPhotoDetailViewControllerWithPhoto(photo)
navigationController.pushViewController(vc, animated: true)
}
}
// Usage
let wireframe = Wireframe(
navigationController: UINavigationController(),
viewControllerFactory: StoryboardViewControllerFactory(
storyboard: UIStoryboard(name: "Name", bundle: nil),
context: NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
)
)
wireframe.presentPhotoDetailsWithPhoto(Photo())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment