Check out the repo instead. The Wisdom of Quinn Now with 100% more archived PDFs.
Informative DevForum posts from everyone's favorite DTS member.
(Arranged newest to oldest)
import Combine | |
import SwiftUI | |
extension View { | |
public func focused<T>(file: StaticString = #file, _ state: FocusState<T>, equals value: T) -> some View { | |
modifier(FocusedModifier(state: state, id: value, file: file)) | |
} | |
} | |
@propertyWrapper |
import SwiftUI | |
extension View { | |
public func discover<T: UIView>( | |
tag: Int = .random(in: (.min)...(.max)), | |
where predicate: @escaping (T) -> Bool = { _ in true }, | |
_ closure: @escaping (T) -> Void | |
) -> some View { | |
self.overlay( | |
DiscoveryView(tag: tag) |
struct SizePreferenceKey: PreferenceKey { | |
static var defaultValue: CGSize = .zero | |
static func reduce(value: inout CGSize, nextValue: () -> CGSize) { | |
value = nextValue() | |
} | |
} | |
struct RelativeSizeModifier: ViewModifier { | |
let percentWidth: CGFloat |
import Darwin | |
import Foundation | |
import UIKit | |
// https://github.com/xybp888/iOS-SDKs/blob/master/iPhoneOS17.1.sdk/System/Library/PrivateFrameworks/CoreSVG.framework/CoreSVG.tbd | |
// https://developer.limneos.net/index.php?ios=17.1&framework=UIKitCore.framework&header=UIImage.h | |
@objc | |
class CGSVGDocument: NSObject { } |
Check out the repo instead. The Wisdom of Quinn Now with 100% more archived PDFs.
Informative DevForum posts from everyone's favorite DTS member.
(Arranged newest to oldest)
struct User: Equatable { | |
var firstName: String | |
var lastName: String | |
} | |
@main | |
struct MyApp: App { | |
@State var value = User(firstName: "", lastName: "") | |
@State var showEdit = false |
import Foundation | |
public protocol CodingStrategy { | |
associatedtype Converted | |
associatedtype RawValue: Codable | |
static func toRaw(_ value: Converted) throws -> RawValue | |
static func toValue(_ raw: RawValue) throws -> Converted | |
} |
/// - returns: `true` when dynamic type is `Equatable` and `==` returns `true`, otherwise `false`. | |
func areEquatablyEqual(_ lhs: Any, _ rhs: Any) -> Bool { | |
func receiveLHS<LHS>(_ typedLHS: LHS) -> Bool { | |
guard | |
let rhsAsLHS = rhs as? LHS | |
else { return false } | |
return areEquatablyEqual(typedLHS, rhsAsLHS) | |
} | |
return _openExistential(lhs, do: receiveLHS) | |
} |
@dynamicMemberLookup | |
struct Combined<A, B> { | |
private let a: A | |
private let b: B | |
init(a: A, b: B) { (self.a, self.b) = (a, b) } | |
subscript<T>(dynamicMember keyPath: KeyPath<A, T>) -> T { | |
return a[keyPath: keyPath] | |
} |
class DictionaryEncoder { | |
init() { } | |
func encode(_ value: Encodable) throws -> [String: Any] { | |
let encoder = _Encoder(codingPath: []) | |
try value.encode(to: encoder) | |
guard let result = encoder.value as? [String: Any] else { | |
throw EncodingError.invalidValue(encoder.value as Any, .init(codingPath: [], debugDescription: "Invalid root container")) | |
} |