Skip to content

Instantly share code, notes, and snippets.

View artyom-stv's full-sized avatar

Artem Starosvetskiy artyom-stv

View GitHub Profile
@artyom-stv
artyom-stv / JSONDecoder+JSONPointer.swift
Last active August 30, 2022 18:17
JSON Pointer support for `JSONDecoder` (see https://www.rfc-editor.org/rfc/rfc6901)
public extension JSONDecoder {
struct CodingPathComponent {
private enum Storage {
case int(Int)
case string(String)
}
var intValue: Int? {
switch storage {
case let .int(value):
@artyom-stv
artyom-stv / gist:a87f572999074aa9afab03d8e96eef2e
Last active February 23, 2023 00:12
Visitor-based approach for accessing `@ViewBuilder`-provided content
// SwiftUI public API
public protocol View {
associatedtype Body: View
var body: Self.Body { get }
}
extension Never: View {
public typealias Body = Never
@artyom-stv
artyom-stv / BoxableTypes.h
Created October 24, 2018 14:31
How to write on Objective-C in 2018. Part 1
// MIT License
//
// Copyright (c) 2018 Joom
//
// 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: