AppDelegate.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.scheduledTimer(withTimeInterval: 3, repeats: true) { [weak self] (_) in
  20. if let self = self {
  21. NSLog("Example log \(self.exampleLogSent)")
  22. self.exampleLogSent += 1
  23. if self.exampleLogSent > self.exampleLogLimit {
  24. self.repeatingLogExampleTimer.invalidate()
  25. }
  26. }
  27. }
  28. // To show off the network logger, send several misc network requests
  29. MiscNetworkRequests.sendExampleRequests()
  30. // For < iOS 13, set up the window here
  31. if ProcessInfo.processInfo.operatingSystemVersion.majorVersion < 13 {
  32. let window = UIWindow(frame: UIScreen.main.bounds)
  33. window.rootViewController = FLEXNavigationController(
  34. rootViewController: CommitListViewController()
  35. )
  36. self.window = window
  37. window.makeKeyAndVisible()
  38. FLEXManager.shared.showExplorer()
  39. }
  40. return true
  41. }
  42. @available(iOS 13.0, *)
  43. func application(_ application: UIApplication,
  44. configurationForConnecting session: UISceneSession,
  45. options: UIScene.ConnectionOptions) -> UISceneConfiguration {
  46. // Called when a new scene session is being created.
  47. // Use this method to select a configuration to create the new scene with.
  48. return UISceneConfiguration(name: nil, sessionRole: session.role)
  49. }
  50. let exampleLogLimit = 10
  51. var exampleLogSent = 0
  52. }