This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIResponder { | |
/// The responder chain from the target responder (self) | |
/// to the `UIApplication` and the app delegate | |
var responderChain: [UIResponder] { | |
var responderChain: [UIResponder] = [] | |
var currentResponder: UIResponder? = self | |
while currentResponder != nil { | |
responderChain.append(currentResponder!) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIWindow { | |
/// Traverse the window's view hierarchy in the same way as the Debug View Hierarchy tool in Xcode. | |
/// | |
/// `traverseHierarchy` uses Depth First Search (DFS) to traverse the view hierarchy starting in the window. This way the method can traverse all sub-hierarchies in a correct order. | |
/// | |
/// - parameters: | |
/// - visitor: The closure executed for every view object in the hierarchy | |
/// - responder: The view object, `UIView`, `UIViewController`, or `UIWindow` instance. | |
/// - level: The depth level in the view hierarchy. | |
func traverseHierarchy(_ visitor: (_ responder: UIResponder, _ level: Int) -> Void) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIWindow { | |
/// Print the app's key window hierarchy. | |
class func printKeyWindowHierarchy() { | |
UIApplication.shared.keyWindow?.printHierarchy() | |
} | |
/// Prints the window's view hierarchy. | |
func printHierarchy() { | |
traverseHierarchy { responder, level in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>beers_on_wall</key> | |
<dict> | |
<key>NSStringLocalizedFormatKey</key> | |
<string>%#@beers@</string> | |
<key>beers</key> | |
<dict> |