Skip to content

Instantly share code, notes, and snippets.

@regularberry
Last active February 22, 2019 21:53
Show Gist options
  • Save regularberry/abbc7a0af431d2bff4b4d910ef941f12 to your computer and use it in GitHub Desktop.
Save regularberry/abbc7a0af431d2bff4b4d910ef941f12 to your computer and use it in GitHub Desktop.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
class InjectedViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("INJECTED VIEW WILL APPEAR")
}
}
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let injected = InjectedViewController()
let simple = UIViewController()
simple.view.setValue(injected, forKeyPath: "_viewDelegate")
window?.addSubview(simple.view)
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment