Skip to content

Instantly share code, notes, and snippets.

Chris Eidhof chriseidhof

Block or report user

Report or block chriseidhof

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View linelimit.swift
import SwiftUI
// Filed: FB6130315
struct Row : View {
let text: String = Array(repeating: "This is a long text that will span multiple lines testing.", count: 3).joined(separator: " ")
var body: some View {
Text(text).lineLimit(nil)
}
}
View small_example.swift
import SwiftUI
struct Sample: View {
@Binding var counter: Int
var body: some View {
VStack {
Text("\(counter)")
Stepper(value: $counter, in: 0...10) {
Text("Stepper")
}
View asyncimages.swift
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
View TodoList.swift
//
// ContentView.swift
// TestingMoreSwiftUI
//
// Created by Chris Eidhof on 04.06.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
import Combine
View 2019-05-14-protocols-vs-functions.md
title synopsis tags share_image episode book collection author
Swift Tip: Protocols vs. Values
Extensible in different ways
news
/images/blog/2019-05-13-protocols-vs-functions.png
19
advanced-swift
networking
chriseidhof
View networking.swift
import Foundation
struct Resource<A> {
var request: URLRequest
var parse: (Data) throws -> A
}
extension Resource where A: Decodable {
init(get url: URL) {
self.init(request: URLRequest(url: url)) { data in
View graph.swift
import Foundation
/*
Talking points
- It's hard for Node to conform to Codable, because of references
- This is a problem in both directions. For encoding, we need to keep track of what we've already seen. For decoding, we need two-phase initialization.
- But we can convert to sparsegraph, and then we get conformance for free
- to do this, an iterator over all reachable nodes really helps!
View nsnorth.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var rootVC: UINavigationController? = nil
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
View fusion.swift
//
// main.swift
// Deforestation
//
// Created by Chris Eidhof on 29.03.19.
// Copyright © 2019 objc.io. All rights reserved.
//
import Foundation
struct Build<Element, Result> {
View ParseLib.swift
//
// ParseLib.swift
// JsxLib
//
// Created by Chris Eidhof on 19.02.19.
//
import Foundation
public struct ParseError: Error {
You can’t perform that action at this time.