Skip to content

Instantly share code, notes, and snippets.

//
// main.swift
// ExtensibleEffects
//
// Created by Chris Eidhof on 02.01.18.
// Copyright © 2018 objc.io. All rights reserved.
//
import Foundation
//
import SwiftUI
struct MyProgress: View, Animatable {
var progress: Double
var animatableData: Double {
get { progress }
set { progress = newValue }
@chriseidhof
chriseidhof / ContentView.swift
Created August 30, 2023 13:12
OnAppearVsTask
import SwiftUI
struct ContentView: View {
@State private var color0 = Color.red
@State private var color1 = Color.red
var body: some View {
VStack {
color0
color1
}
//
import SwiftUI
import Observation
// easeInBounce
//
// https://easings.net
// https://gist.github.com/girish3/11167208
@chriseidhof
chriseidhof / goroutines.swift
Created February 16, 2018 12:36
goroutines.swift
import Foundation
protocol Channel: IteratorProtocol {
func send(_ value: Element?)
}
/// A blocking channel for sending values.
///
/// `send` and `receive` must run in separate separate execution contexts, otherwise you get a deadlock.
final class BlockingChannel<A>: Channel {
//
// Diagrams.swift
// DiagramsSample
//
// Created by Chris Eidhof on 16.12.19.
// Copyright © 2019 objc.io. All rights reserved.
//
import SwiftUI
@chriseidhof
chriseidhof / nsincrementalstore.markdown
Created February 18, 2012 16:39
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@chriseidhof
chriseidhof / parsing.swift
Last active April 16, 2023 02:38
JSON Parsing in Swift
// This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html
//
// As of Beta5, the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
@chriseidhof
chriseidhof / swiftui.swift
Last active March 15, 2023 06:53
SwiftUI - iOS
import Combine
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
import Foundation
import SwiftUI
import UIKit
import os.log
import os
@chriseidhof
chriseidhof / script.swift
Last active February 21, 2023 05:12
SwiftUI
import SwiftSyntax
import SwiftSemantics
import Foundation
let source = try! String(contentsOf: URL(fileURLWithPath: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64e.swiftinterface"))
var collector = DeclarationCollector()
let tree = try SyntaxParser.parse(source: source)
tree.walk(&collector)