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 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")) | |
} |
import Foundation | |
import NIO | |
import NIOHTTP1 | |
// Inspired/parts copied from http://www.alwaysrightinstitute.com/microexpress-nio/ | |
final class HelloHandler: ChannelInboundHandler { | |
typealias InboundIn = HTTPServerRequestPart | |
func channelRead(ctx: ChannelHandlerContext, data: NIOAny) { |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse