Skip to content

Instantly share code, notes, and snippets.

Avatar

Chase Wasden ccwasden

View GitHub Profile
View Await+Threading.swift
//
// Author: Chase Wasden
// Website: https://gist.github.com/ccwasden
// Licensed under MIT license https://opensource.org/licenses/MIT
//
import Foundation
import Combine
// Threading
View Multiselect.swift
//
// Author: Chase Wasden
// Website: https://gist.github.com/ccwasden
// Licensed under MIT license https://opensource.org/licenses/MIT
//
import SwiftUI
struct Fruit: Selectable {
let name: String
@ccwasden
ccwasden / Multiselect2.swift
Last active Apr 29, 2020
Swift multiselect
View Multiselect2.swift
//
// Author: Chase Wasden
// Website: https://gist.github.com/ccwasden
// Licensed under MIT license https://opensource.org/licenses/MIT
//
import SwiftUI
struct Fruit: Selectable {
let name: String
@ccwasden
ccwasden / Multiselect3.swift
Last active Apr 7, 2020
Multiselect using a custom property wrapper - Modified from child view through a Binding
View Multiselect3.swift
//
// Author: Chase Wasden
// Website: https://gist.github.com/ccwasden
// Licensed under MIT license https://opensource.org/licenses/MIT
//
import SwiftUI
struct Fruit: Identifiable {
let name: String
@ccwasden
ccwasden / SwiftUI-MultiSelect.swift
Last active Apr 7, 2020
Multiselect using ObservableObject with child array - Modified from child view through a Binding
View SwiftUI-MultiSelect.swift
struct Cheese: Identifiable {
let name: String
var isSelected: Bool
var id: String { name }
}
class ViewModel: ObservableObject {
@Published var cheeses = [
Cheese(name: "Brie", isSelected: false),
Cheese(name: "Cheddar", isSelected: true),
@ccwasden
ccwasden / WithPopover.swift
Created Feb 5, 2020
Custom size popover in iOS SwiftUI
View WithPopover.swift
// -- Usage
struct Content: View {
@State var open = false
@State var popoverSize = CGSize(width: 300, height: 300)
var body: some View {
WithPopover(
showPopover: $open,
popoverSize: popoverSize,
@ccwasden
ccwasden / automateSandboxTesterEntry.js
Last active Oct 3, 2018
Automate rapid/fast creation of sandbox testers in itunesConnect
View automateSandboxTesterEntry.js
// Steps to use:
// 1. Go to itunesConnect > Users & Roles
// 2. Select "Testers" under the "Sandbox" header on the left
// 2. Open the console on your browser (eg. CMD-OPT-J)
// 3. Paste the code below (modified to your liking) into the console and hit enter
// 4. enter `createUser('desiredEmailAlias')` into the console and watch the user get created automatically
//
// NOTE: To create several users rapidly: in the console hit the up arrow, change the alias, and hit enter again. Repeat.
// Edit the user here to your liking
@ccwasden
ccwasden / ArrayUtils.swift
Created Jan 31, 2015
Some generic array utilities I use
View ArrayUtils.swift
func unwrapAndCollapse<T>(array:[T?]) -> [T] {
return array.reduce([]) { $1 != nil ? $0 + [$1!] : $0 }
}
func appendReplacingMatches<T>(first:[T], second:[T], matcher:((T,T)->Bool)) -> [T] {
var i = 0
var finalArray = first
var appendArray = second
while i < first.count && appendArray.count > 0 {
let item = appendArray.first!