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 UIKit.UIView { | |
| public class Animator { | |
| fileprivate var animatorBlock: ((@escaping () -> (), @escaping (Bool) -> ()) -> ()) | |
| fileprivate var animations: () -> () = { _ in } | |
| public init(animatorBlock: @escaping ((@escaping () -> (), @escaping (Bool) -> ()) -> ())) { | |
| self.animatorBlock = animatorBlock | |
| } | |
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
| public class func animation(withDuration duration: TimeInterval) -> (@escaping () -> ()) -> (@escaping (Bool) -> ()) -> Void { | |
| return { (animations: @escaping () -> ()) in | |
| return { (completion: @escaping (Bool) -> ()) in | |
| UIView.animate(withDuration: duration, animations: animations, completion: completion) | |
| } | |
| } | |
| } |
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
| enum Planets { | |
| case Mercury | |
| case Venus | |
| case Earth | |
| case Mars | |
| case Jupiter | |
| static let count: Int = _count() | |
| private static func _count(_ first: Planets = .Mercury) -> Int { | |
| print("blahp") |
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
| //global macro helpers | |
| #define DH_Str(I) #I | |
| #define __DH_STRING_ENUM(PREFIX, SUFFIX, PREFIX2, SUFFIX2) \ | |
| static PREFIX PREFIX##_##SUFFIX = @DH_Str(PREFIX2##SUFFIX2); | |
| #define _DH_STRING_ENUM2(PREFIX, SUFFIX, VAL) \ | |
| static PREFIX PREFIX##_##SUFFIX = VAL; | |
| #define _DH_STRING_ENUM(T,I) \ | |
| __DH_STRING_ENUM(T, I, T, I) | |
| //------ file dependent | |
| // the enum type shall be DHBlahKey |
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
| import UIKit | |
| // discourage directly setting property m by using private(set). Anyone can still set the value of the property via setValue(_ :forKey:) | |
| public class Abe: NSObject { | |
| public private(set) var m: [String] = ["abc"] | |
| } | |
| public class Billy: Abe { | |
| override init() { |
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
| enum PageNames: String { | |
| case sc🖍search = "MySearch" | |
| var page_name: String { | |
| return String(describing: self).replacingOccurrences(of: "🖍", with: "/") | |
| } | |
| } | |
| PageNames.sc🖍search.rawValue // "MySearch" |
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
| // This is a conditional inclusion. | |
| // It searches for a file called Captain.xcconfig that lives one file level up in relation to this file. | |
| #include? "../Captain.xcconfig" |
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
| #if ABC | |
| // Code between here that runs only when ABC exists | |
| #endif |
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
| ABC_OBJC=ABC=1 | |
| ABC_SWIFT=ABC |
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
| #if DEBUG | |
| print("print debug value", x) | |
| #endif |