๐
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 SwiftUI | |
import UIKit | |
private struct BodyCounterView: UIViewRepresentable { | |
let color: UIColor | |
private let id = UUID() // Force view updates | |
func makeUIView(context: Context) -> _BodyCounterView { | |
let view = _BodyCounterView() |
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
// Sample code made in response to this tweet: | |
// https://twitter.com/stroughtonsmith/status/1485719749673820163 | |
final class MainView: UIView { | |
private let textView: UITextView = { | |
let this = UITextView() | |
this.translatesAutoresizingMaskIntoConstraints = false | |
this.text = "I'm a text view" | |
this.font = .preferredFont(forTextStyle: .body) | |
this.textColor = .label |
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/UIKit.h> | |
typedef NS_ENUM(NSInteger, DBGInterfaceStyleOverride) { | |
DBGInterfaceStyleOverrideNone = 0, | |
DBGInterfaceStyleOverrideLight, | |
DBGInterfaceStyleOverrideDark, | |
}; | |
#ifdef __cplusplus | |
extern "C" { |
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
@propertyWrapper | |
struct Redraw<Value> { | |
var wrappedValue: Value | |
init(wrappedValue: Value) { | |
self.wrappedValue = wrappedValue | |
} | |
static subscript<Instance: UIView>( | |
_enclosingInstance instance: Instance, |
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
// | |
// UIView+Tooltips.h | |
// Crossword | |
// | |
// Created by Steven Troughton-Smith on 13/09/2019. | |
// Copyright ยฉ 2019 Steven Troughton-Smith. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |
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 Foundation | |
extension String { | |
func hyphenated(languageCode: String) -> String { | |
let locale = Locale(identifier: languageCode) | |
return self.hyphenated(locale: locale) | |
} | |
func hyphenated(locale: Locale) -> String { |
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
let emojis: [String: [String]] = [ | |
// +[EMFEmojiCategory TravelAndPlacesEmoji] | |
"travel": ["๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ด", "๐ฒ", "๐ต", "๐", "๐จ", "๐", "๐", "๐", "๐", "๐ก", "๐ ", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ฉ", "โ๏ธ", "๐ซ", "๐ฌ", "๐", "๐ฐ", "๐บ", "๐ถ", "โต๏ธ", "๐ฅ", "๐ค", "๐ณ", "โด", "๐ข", "โ๏ธ", "๐ง", "โฝ๏ธ", "๐", "๐ฆ", "๐ฅ", "๐บ", "๐ฟ", "๐ฝ", "โฒ๏ธ", "๐ผ", "๐ฐ", "๐ฏ", "๐", "๐ก", "๐ข", "๐ ", "โฑ", "๐", "๐", "โฐ", "๐", "๐ป", "๐", "๐", "๐", "โบ๏ธ", "๐ค", "๐ฃ", "๐", "๐ญ", "๐ ", "๐ก", "๐", "๐", "๐ข", "๐ฌ", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐จ", "๐ช", "๐ซ", "๐ฉ", "๐", "๐", "โช๏ธ", "๐", "๐", "๐", "โฉ", "๐พ", "๐", "๐", "๐ ", "๐", "๐ ", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐"], | |
// +[EMFEmojiCategory NatureEmoji] | |
"nature": ["๐ถ", "๐ฑ", "๐ญ", "๐น", "๐ฐ", "๐ฆ", "๐ป", "๐ผ", "๐จ", "๐ฏ", "๐ฆ", "๐ฎ", "๐ท", "๐ฝ", "๐ธ", "๐ต", "๐", "๐", "๐", "๐", "๐", "๐ง", "๐ฆ", "๐ค", "๐ฃ", "๐ฅ", "๐ฆ", "๐ฆ ", "๐ฆ", "๐ฆ", "๐บ", "๐", "๐ด", "๐ฆ", "๐", "๐", "๐ฆ", "๐", "๐", "๐", "๐", "๐ท", "๐ธ", "๐ข", "๐", "๐ฆ", "๐ฆ", "๐ฆ", "๐ฆ", "๐", "๐ฆ", "๐ ", "๐", "๐ก", "๐ฌ", "๐ฆ |
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 Foundation | |
// Alternatives to `Scanner` (before: `NSScanner`). | |
// A scanner only needs a way to peek and to move to the next token. | |
protocol ScannerProtocol { | |
associatedtype Token: Equatable | |
var peek: Token? { get } | |
mutating func moveToNextToken() |
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 Foundation | |
final class Sample: NSObject { | |
@objc dynamic var name: String = "" | |
} | |
class MyObj: NSObject { | |
@objc dynamic var test: String = "" | |
} | |
extension NSObjectProtocol where Self: NSObject { |
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 Foundation | |
// A lens is a getter and a setter combined | |
struct Lens<Whole, Part> { | |
let get: (Whole) -> Part | |
let set: (inout Whole, Part) -> () | |
} | |
// We can create a lens from a key path | |
extension Lens { |
NewerOlder