Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
chriseidhof / SimpleRepresentable.swift
Last active September 8, 2023 07:12 — forked from vincefried/SimpleRepresentable.swift
A small demonstration of how I would like a way to modify a wrapped UIView.
import UIKit
import SwiftUI
struct ContentView2: View {
var body: some View {
VStack {
SimpleRepresentable(text: "Test")
}
}
}
import SwiftUI
extension View {
func pipe<R>(@ViewBuilder _ f: (Self) -> R) -> R {
f(self)
}
}
struct ContentView: View {
@State var flag: Bool = false
@chriseidhof
chriseidhof / ContentView.swift
Created February 20, 2021 17:19 — forked from steipete/ContentView.swift
FB9013209: SwiftUI: Preview and actual layout differ in this example. (SwiftUI Bug)
//
// ContentView.swift
// Shared
//
// Created by Peter Steinberger on 20.02.21.
//
import SwiftUI
struct SettingsGroup<Content: View>: View {
//: A Cocoa based Playground to present user interface
import SwiftUI
struct ContentView: View {
var body: some View {
HStack {
Text("Highlight :")
.background(Color.green)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
@chriseidhof
chriseidhof / ob-swiftui.el
Last active May 25, 2020 23:56 — forked from xenodium/ob-swiftui.el
Preview SwiftUI layouts using Emacs org blocks
(use-package org
:hook ((org-mode . org-display-inline-images))
:config
(use-package ob
:bind (:map org-mode-map
("C-c C-c" . org-ctrl-c-ctrl-c))
:config
(use-package ob-swift
//
// ContentView.swift
// FlowLayoutST
//
// Created by Chris Eidhof on 22.08.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
struct FlowLayout {
@chriseidhof
chriseidhof / Routing.swift
Last active May 13, 2018 06:06 — forked from gonzalonunez/Routing.swift
Routing Problem
import Foundation
struct Handler {
let handleJSON: (Data) throws -> Void
init<T: Decodable>(handler: @escaping (T) -> Void) {
handleJSON = { data in
let object = try JSONDecoder().decode(T.self, from: data)
handler(object)
}
@chriseidhof
chriseidhof / eat_seek_peek.swift
Last active May 13, 2018 23:19 — forked from milseman/eat_seek_peek.swift
Playground for Self-sliced Collections: eat/seek/peek
// Eat/seek/peek
extension Collection where SubSequence == Self, Element: Equatable {
mutating func eat(_ element: Element) -> Bool {
guard let f = first, f == element else { return false }
eat()
return true
}
mutating func eat(asserting on: Element) -> Element {
@chriseidhof
chriseidhof / eat_seek_peek.swift
Created March 1, 2018 07:20 — forked from milseman/eat_seek_peek.swift
Playground for Self-sliced Collections: eat/seek/peek
// Eat/seek/peek
extension Collection where SubSequence == Self, Element: Equatable {
mutating func eat() -> Element {
defer { self = self.dropFirst() }
return peek()
}
mutating func eat(_ n: Int) -> SubSequence {
let (pre, rest) = self.seek(n)
defer { self = rest }

Hey everyone!

Thanks once again for buying the pre-release version, we're very happy with the response so far. This week we'll release the (first part of) the model-view-controller chapter. Some bits are still missing, and some bits still under construction, but we hope you'll enjoy it.

We recorded our first Q&A video, thanks to everyone who asked questions. Recording between two continents is a bit hard, so sorry for the low quality — we're still trying to find the button to keep Matt's face visible in the corner. But we're working on it! If you have any questions for next week, please do ask, either by filing issues or sending us a tweet. We'd love to see some questions sent as videos.

You may have heard Chris on the Swift By Sundell podcast last week; he talked