This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// | |
// SwiftUI.List appears to iterate all the way including the endIndex | |
// which causes a crash. LazyVStack and ForEach do not do have this issue | |
// | |
// Refer to other GIST where there is no backing storage for the custom collection | |
// https://gist.github.com/jeffreybergier/0a366e173a871c1a8f3828824dbf7a54 | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// | |
// SwiftUI.List appears to iterate all the way including the endIndex | |
// which causes a crash. LazyVStack and ForEach do not do have this issue | |
// | |
// | |
import SwiftUI | |
@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension NSAttributedString { | |
var image: UIImage { | |
let options: NSStringDrawingOptions = [ .usesLineFragmentOrigin, .usesFontLeading, .usesDeviceMetrics ] | |
let rect = boundingRect(with: self.size(), options: options, context: nil) | |
return UIGraphicsImageRenderer(bounds: rect).image { _ in | |
draw(at: .zero) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Direction { | |
case right, left, up, down | |
} | |
func traverseClockwise(_ input: [[String]]) -> [String] { | |
// used to calculate how long the output needs to be | |
let countY = input.count | |
let countX = input.first?.count ?? 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// | |
// | |
// // This file should be multiple files | |
// // But because multiple JS files take multiple round trips | |
// // Putting it in one for now | |
// | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I've tried several combos | |
// I'll list each one and the error it gives | |
// #1 Playground execution failed: error: Untitled Page 2.xcplaygroundpage:4:24: error: cannot specialize non-generic type 'MyWeirdDictionaryDelegate' | |
protocol MyWeirdDictionaryDelegate: class { | |
associatedtype K | |
func willSet(value: K, forKey key: String) -> K? | |
func willReturn(value: K?, forKey: String) -> K? | |
} | |
class MyWeirdDictionary<T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Remindable.swift | |
// WaterMe | |
// | |
// Created by Jeffrey Bergier on 5/7/16. | |
// | |
// Copyright (c) 2015 Jeffrey Bergier | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PurchaseManager.swift | |
// GratuitousSwift | |
// | |
// Created by Jeffrey Bergier on 9/30/15. | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is |