This file contains 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 UserNotifications | |
// 1. Request Permission | |
func requestAuthorization() { | |
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (granted, error) in | |
if granted { | |
// Success | |
} else { | |
// Error | |
print(error?.localizedDescription) |
This file contains 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 protocol Localizable { | |
func localize() | |
} | |
public extension Localizable { | |
public func localize(_ string: String?) -> String? { | |
guard let term = string, term.hasPrefix("@") else { | |
return string | |
} |
*** Install Xcode first for save the time *** Homebrew need xcode command line tools first
Install Git and bash-completion:
brew install git && brew install bash-completion
This file contains 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
private let swizzling: (AnyClass, Selector, Selector) -> () = { forClass, originalSelector, swizzledSelector in | |
let originalMethod = class_getInstanceMethod(forClass, originalSelector) | |
let swizzledMethod = class_getInstanceMethod(forClass, swizzledSelector) | |
method_exchangeImplementations(originalMethod!, swizzledMethod!) | |
} | |
extension UIViewController { | |
static let swizzled: Void = { | |
let originalSelector = #selector(viewDidLoad) | |
let swizzledSelector = #selector(swizzled_viewDidload) |
OlderNewer