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
/** Handle UIControl event closure-base instead of (target/action) | |
Example: | |
```swift | |
// Button | |
button.on(.touchUpInside) { btn in | |
print("Button clicked") | |
} | |
// TextField | |
textField.on(.editingChanged) { tf in |
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
// From this | |
didFinishLoading = { [weak self] in | |
guard let self = self else { return } | |
self.tableView.reloadData() | |
} | |
// To this | |
didFinishLoading = weaker(self) { s in | |
// No more boilerplate code :) | |
s.tableView.reloadData() |
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 UIKit | |
import Foundation | |
func generateQR(from string: String) -> Data? { | |
let data = string.data(using: String.Encoding.utf8) | |
guard let qrFilter = CIFilter(name: "CIQRCodeGenerator") else { return nil } | |
qrFilter.setValue(data, forKey: "inputMessage") | |
NewerOlder