AppDelegate.swift 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // AppDelegate.swift
  3. // FLEXample
  4. //
  5. // Created by Tanner on 3/11/20.
  6. // Copyright © 2020 Flipboard. All rights reserved.
  7. //
  8. import UIKit
  9. @UIApplicationMain @objcMembers
  10. class AppDelegate: UIResponder, UIApplicationDelegate {
  11. var repeatingLogExampleTimer: Timer!
  12. var window: UIWindow?
  13. func application(_ application: UIApplication,
  14. didFinishLaunchingWithOptions options: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  15. FLEXManager.shared.isNetworkDebuggingEnabled = true
  16. // Add at least oen custom user defaults key to explore
  17. UserDefaults.standard.set("foo", forKey: "FLEXamplePrefFoo")
  18. // To show off the system log viewer, send 10 example log messages at 3 second intervals
  19. self.repeatingLogExampleTimer = Timer(
  20. timeInterval: 3, target: self,
  21. selector: #selector(sendExampleLogMessage),
  22. userInfo: nil, repeats: true
  23. )
  24. // To show off the network logger, send several misc network requests
  25. MiscNetworkRequests.sendExampleRequests()
  26. // For < iOS 13, set up the window here
  27. if ProcessInfo.processInfo.operatingSystemVersion.majorVersion < 13 {
  28. let window = UIWindow(frame: UIScreen.main.bounds)
  29. window.rootViewController = FLEXNavigationController(
  30. rootViewController: CommitListViewController()
  31. )
  32. self.window = window
  33. window.makeKeyAndVisible()
  34. FLEXManager.shared.showExplorer()
  35. }
  36. return true
  37. }
  38. @available(iOS 13.0, *)
  39. func application(_ application: UIApplication,
  40. configurationForConnecting session: UISceneSession,
  41. options: UIScene.ConnectionOptions) -> UISceneConfiguration {
  42. // Called when a new scene session is being created.
  43. // Use this method to select a configuration to create the new scene with.
  44. return UISceneConfiguration(name: nil, sessionRole: session.role)
  45. }
  46. let exampleLogLimit = 10
  47. var exampleLogSent = 0
  48. func sendExampleLogMessage() {
  49. NSLog("Example log \(self.exampleLogSent)")
  50. self.exampleLogSent += 1
  51. if self.exampleLogSent > self.exampleLogLimit {
  52. self.repeatingLogExampleTimer.invalidate()
  53. }
  54. }
  55. }