Skip to content

Instantly share code, notes, and snippets.

View PaulWoodIII's full-sized avatar

Paul Wood III PaulWoodIII

View GitHub Profile
@PaulWoodIII
PaulWoodIII / SelectedItems.swift
Created August 19, 2019 00:02
quick example of how to use selection in a SwiftUI list, an ObservableObject provides the content as well
//: [Previous](@previous)
import SwiftUI
import Combine
import PlaygroundSupport
class Context: ObservableObject {
@Published var selectedItems: Set<String>
@Published var items: Array<String>
@PaulWoodIII
PaulWoodIII / SelectedItems.swift
Created August 19, 2019 00:36
SwiftUI does not select items with this code
//
// SelectedItems.swift
// OrderedList
//
// Created by Paul Wood on 8/18/19.
// Copyright © 2019 Paul Wood. All rights reserved.
//
import SwiftUI
import Combine
@PaulWoodIII
PaulWoodIII / SelectedItems+ItemIsAClass.swift
Created August 19, 2019 00:41
selected items are not selected if the Item type is a reference instead of a value as well
//
// SelectedItems.swift
// OrderedList
//
// Created by Paul Wood on 8/18/19.
// Copyright © 2019 Paul Wood. All rights reserved.
//
import SwiftUI
import Combine
@PaulWoodIII
PaulWoodIII / SingleyLinkedList.swift
Created August 19, 2019 23:57
A playground and implementation of a SingleLinkedList in Swift
//: [Previous](@previous)
import Foundation
class SingleyLinkedList: CustomStringConvertible, Sequence {
struct Iterator: Swift.IteratorProtocol {
typealias Element = Int
internal var nextValue: SLLNode?
mutating func next() -> Int? {

Keybase proof

I hereby claim:

  • I am paulwoodiii on github.
  • I am paulwoodiii (https://keybase.io/paulwoodiii) on keybase.
  • I have a public key whose fingerprint is 4CFB 8CC8 7E0B B82F 81C8 36A2 2780 1CCB 13EA 9566

To claim this, I am signing this object:

@PaulWoodIII
PaulWoodIII / SwapSwiftUI.swift
Created August 21, 2019 11:39
SwiftUI Swap the position of an element in a Stack View with animation
import SwiftUI
extension String: Identifiable {
public var id: String { return self }
}
struct ContentView: View {
@State var list: [String] = ["Hello", "World"]
@PaulWoodIII
PaulWoodIII / InsertionSortView.swift
Created August 21, 2019 13:25
Insertion Sort Visualized on the Apple Watch using SwiftUI
//
// ContentView.swift
// WatchSort WatchKit Extension
//
// Created by Paul Wood on 8/21/19.
// Copyright © 2019 Paul Wood. All rights reserved.
//
// InsertionSortArray take from Apple's Sample Code and modified for SwiftUI
// https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/using_collection_view_compositional_layouts_and_diffable_data_sources
// Check out the talk on diffable datasources here: https://developer.apple.com/videos/play/wwdc2019/220
@PaulWoodIII
PaulWoodIII / BinarySearchView.swift
Created August 22, 2019 15:49
bare minimum to simply display a representation of a binary search tree in SwiftUI with some graphical context
//
// BinarySearchView.swift
// WatchSort WatchKit Extension
//
// Created by Paul Wood on 8/22/19.
// Copyright © 2019 Paul Wood. All rights reserved.
//
import SwiftUI
import Combine
@PaulWoodIII
PaulWoodIII / BinarySearchView.swift
Created August 23, 2019 01:01
Binary Search visualized on the Apple Watch, Swiftsy Bitsy Datastructures and Algorithms
//
// BinarySearchView.swift
// WatchSort WatchKit Extension
//
// Created by Paul Wood on 8/22/19.
// Copyright © 2019 Paul Wood. All rights reserved.
//
import SwiftUI
import Combine
@PaulWoodIII
PaulWoodIII / BinarySortTreeInsertionView.swift
Created August 23, 2019 18:15
Binary Sort Visualized based on insertion order you can see a different BST. This displays why you randomize insertion of a BST
//
// ContentView.swift
// BinarySearchVisualized
//
// Created by Paul Wood on 8/23/19.
// Copyright © 2019 Paul Wood. All rights reserved.
//
import SwiftUI
import Combine