You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
1.1 KiB

2 years ago
  1. //
  2. // UIViewController+StoryboardViewControllerResource.swift
  3. // R.swift.Library
  4. //
  5. // Created by Mathijs Kadijk on 13-03-16.
  6. // From: https://github.com/mac-cain13/R.swift.Library
  7. // License: MIT License
  8. //
  9. import Foundation
  10. import UIKit
  11. public extension UIStoryboard {
  12. /**
  13. Instantiates and returns the view controller with the specified resource (R.storyboard.*.*).
  14. - parameter resource: An resource (R.storyboard.*.*) that uniquely identifies the view controller in the storyboard file. If the specified resource does not exist in the storyboard file, this method raises an exception.
  15. - returns: The view controller corresponding to the specified resource (R.storyboard.*.*). If no view controller is associated, this method throws an exception.
  16. */
  17. func instantiateViewController<ViewControllerResource: StoryboardViewControllerResourceType>(withResource resource: ViewControllerResource) -> ViewControllerResource.ViewControllerType? {
  18. return self.instantiateViewController(withIdentifier: resource.identifier) as? ViewControllerResource.ViewControllerType
  19. }
  20. }