AppDelegate.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. func application(_ application: UIApplication,
  13. didFinishLaunchingWithOptions options: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  14. FLEXManager.shared.isNetworkDebuggingEnabled = true
  15. // Add at least oen custom user defaults key to explore
  16. UserDefaults.standard.set("foo", forKey: "FLEXamplePrefFoo")
  17. // To show off the system log viewer, send 10 example log messages at 3 second intervals
  18. self.repeatingLogExampleTimer = Timer(
  19. timeInterval: 3, target: self,
  20. selector: #selector(sendExampleLogMessage),
  21. userInfo: nil, repeats: true
  22. )
  23. // To show off the network logger, send several misc network requests
  24. MiscNetworkRequests.sendExampleRequests()
  25. return true
  26. }
  27. func application(_ application: UIApplication,
  28. configurationForConnecting session: UISceneSession,
  29. options: UIScene.ConnectionOptions) -> UISceneConfiguration {
  30. // Called when a new scene session is being created.
  31. // Use this method to select a configuration to create the new scene with.
  32. return UISceneConfiguration(name: nil, sessionRole: session.role)
  33. }
  34. let exampleLogLimit = 10
  35. var exampleLogSent = 0
  36. func sendExampleLogMessage() {
  37. NSLog("Example log \(self.exampleLogSent)")
  38. self.exampleLogSent += 1
  39. if self.exampleLogSent > self.exampleLogLimit {
  40. self.repeatingLogExampleTimer.invalidate()
  41. }
  42. }
  43. }