Skip to content

Instantly share code, notes, and snippets.

FB7671513

If you run the code below in a playground you will see that tapping the buttons doesn’t change the UI.

However, if you move the GeometryReader to the outside of ViewModelView it will begin working again.

import SwiftUI
import PlaygroundSupport
@chriseidhof
chriseidhof / sample.swift
Last active February 25, 2024 16:04
View Inspection
import SwiftUI
struct SizeKey: PreferenceKey {
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) {
value = value ?? nextValue()
}
}
struct ContentView: View {
@State var width: CGFloat? = nil
var body: some View {
@natecook1000
natecook1000 / operatorCharacters.swift
Last active January 3, 2024 21:33
Allowed characters for Swift operators
import Foundation
extension UnicodeScalar : ForwardIndexType {
public func successor() -> UnicodeScalar {
return UnicodeScalar(value + 1)
}
}
var operatorHeads: [UnicodeScalar] = Array("=-+!*%<>&|^~?".unicodeScalars)
operatorHeads += Array("\u{00A1}" ... "\u{00A7}")
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 18, 2024 00:56
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@adamgit
adamgit / .gitignore
Last active April 8, 2024 12:58
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#