Skip to content

Instantly share code, notes, and snippets.

View krzysztofzablocki's full-sized avatar

Krzysztof Zabłocki krzysztofzablocki

View GitHub Profile
//
// ContentView.swift
// ComposableTest
//
import ComposableArchitecture
import SwiftUI
struct ContentView: View {
var store: Store<Main.State, Main.Action>
@HashNuke
HashNuke / SwiftUI-SplitView-MacOS.swift
Last active January 5, 2024 18:53
Using a NSSplitViewController with SwiftUI on mac to render SwiftUI views as split panes. Drop this code into a playground to try it out. SORRY MAC-OS ONLY. DOES NOT WORK ON IOS
import AppKit
import SwiftUI
// Delete this line if not using a playground
import PlaygroundSupport
struct ContentView: View {
var body: some View {
// if spacing is not set to zero, there will be a gap after the first row
// Created by Sean Heber (@BigZaphod) on 10/12/19.
// License: BSD
import Foundation
//==---------------------------------------------------------
/// This implementation requires the ability to initialize an
/// instance of a type before it can decode it. This is to support
/// reference types automatically so that each instance is
/// only stored once in the archive. Decoding a reference
@darrarski
darrarski / FormattedTextField.swift
Last active April 16, 2024 13:14
SwiftUI FormattedTextField - TextField with custom display/edit formatters
import SwiftUI
public struct FormattedTextField<Formatter: TextFieldFormatter>: View {
public init(_ title: String,
value: Binding<Formatter.Value>,
formatter: Formatter) {
self.title = title
self.value = value
self.formatter = formatter
}
@sukov
sukov / CodableExtension.swift
Last active November 25, 2022 17:27 — forked from mikebuss/decode-json-swift.swift
Codable (Encode & Decode) [Any] and [String: Any] Swift 5
// Original: https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24
import Foundation
private struct JSONCodingKeys: CodingKey {
var stringValue: String
init(stringValue: String) {
self.stringValue = stringValue
}
@IanKeen
IanKeen / KeypathUpdatable.swift
Created February 15, 2018 20:03
A simpler swifty lens pattern
public protocol KeypathUpdatable {
func update<T>(_ keyPath: WritableKeyPath<Self, T>, to value: T) -> Self
}
public extension KeypathUpdatable {
public func update<T>(_ keyPath: WritableKeyPath<Self, T>, to value: T) -> Self {
var copy = self
copy[keyPath: keyPath] = value
return copy
}
@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra

@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@ZevEisenberg
ZevEisenberg / LICENSE
Last active February 19, 2022 02:04
Smoothly deselect table and collection view cells on dismissal, including interactive dismiss and interactively-partially-dismiss-then-cancel-then-dismiss-again
The MIT License (MIT)
Copyright (c) 2016 Zev Eisenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@mcmurrym
mcmurrym / MirrorDebugDecscription.swift
Last active December 24, 2019 05:59
A default protocol implementation for CustomDebugStringConvertible that uses Mirror for introspection
public extension CustomDebugStringConvertible {
var debugDescription: String {
return debugDescription()
}
func debugDescription(_ indentationLevel: Int = 0, includeType: Bool = true) -> String {
let indentString = (0..<indentationLevel).reduce("") { tabs, _ in tabs + "\t" }
var s: String