Skip to content

Instantly share code, notes, and snippets.

@atdrendel
atdrendel / ReduceLatest.swift
Last active February 28, 2022 14:53
ReduceLatest is a custom Combine publisher that transforms upstream publishers' data and sends the new value downstream whenever any upstream publisher publishes.
import Combine
import Foundation
public extension Publisher {
func reduceLatest<B: Publisher, Output>(
_ b: B,
_ transform: @escaping (Self.Output?, B.Output?) -> Output
) -> Publishers.ReduceLatest<Self, B, Output> {
Publishers.ReduceLatest(self, b, transform)
}
@atdrendel
atdrendel / encodable-dictionary.swift
Created August 22, 2018 09:49
Encoding Dictionary<String, String>
extension Dictionary where Key==String, Value==String {
struct DictCodingKey: CodingKey {
var stringValue: String
init(stringValue: String) {
self.stringValue = stringValue
}
var intValue: Int? { return nil }
init?(intValue: Int) { return nil }
}
@atdrendel
atdrendel / debug.xcconfig
Last active May 11, 2023 11:50
Xcode configuration for iOS, macOS, watchOS, and tvOS framework
// -*- SHARED -*-
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator
COMBINE_HIDPI_IMAGES = YES
INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks
SKIP_INSTALL = YES
COPY_PHASE_STRIP = NO
IPHONEOS_DEPLOYMENT_TARGET = 14.0
MACOSX_DEPLOYMENT_TARGET = 10.15
TVOS_DEPLOYMENT_TARGET = 14.0