Print.swift 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Print.swift
  3. // SideMenu
  4. //
  5. // Created by Jon Kent on 12/5/18.
  6. //
  7. import Foundation
  8. internal enum Print: String { case
  9. cannotPush = "Attempt to push a View Controller from %@ where its navigationController == nil. It must be embedded in a UINavigationController for this to work.",
  10. emptyMenu = "The menu doesn't have a view controller to show! SideMenuNavigationController needs a view controller to display just like a UINavigationController.",
  11. menuAlreadyAssigned = "%@ was already assigned to the %@ of %@. When using multiple SideMenuManagers you may want to use new instances of SideMenuNavigationController instead of existing instances to avoid crashes if the menu is presented more than once.",
  12. menuInUse = "%@ cannot be modified while it's presented.",
  13. panGestureAdded = "%@ was called before %@ or %@ was set. Gestures will not work without a menu.",
  14. property = "A menu's %@ property can only be changed when it is hidden.",
  15. screenGestureAdded = "%@ was called before %@ was set. The gesture will not work without a menu. Use %@ to add gestures for only one menu.",
  16. transitioningDelegate = "SideMenu requires use of the transitioningDelegate. It cannot be modified."
  17. enum PropertyName: String { case
  18. leftSide
  19. }
  20. static func warning(_ print: Print, arguments: CVarArg..., required: Bool = false) {
  21. warning(String(format: print.rawValue, arguments: arguments), required: required)
  22. }
  23. static func warning(_ print: Print, arguments: PropertyName..., required: Bool = false) {
  24. warning(String(format: print.rawValue, arguments: arguments.map { $0.rawValue }), required: required)
  25. }
  26. static func warning(_ print: Print, required: Bool = false) {
  27. warning(print.rawValue, required: required)
  28. }
  29. }
  30. private extension Print {
  31. static func warning(_ message: String, required: Bool = false) {
  32. let message = "SideMenu Warning: \(message)"
  33. if required {
  34. print(message)
  35. return
  36. }
  37. #if !STFU_SIDEMENU
  38. print(message)
  39. #endif
  40. }
  41. }