This file contains hidden or 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 SwiftUI | |
enum Style: String, CaseIterable { | |
case grouped, inset, insetGrouped, plain, sidebar | |
} | |
struct ContentView: View { | |
@State private var selectedStyle: Style = .plain | |
var body: some View { |
This file contains hidden or 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
public func printDetail( _ items: Any..., | |
fileID: String = #fileID, | |
function: String = #function, | |
line: Int = #line, | |
separator: String = " ", | |
terminator: String = "\n") { | |
print("___________________________") | |
print(items.map{ "\($0)" }.joined(separator: separator)) | |
print( | |
""" |
This file contains hidden or 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
// | |
// Created for ErrorAlert | |
// by Stewart Lynch on 2022-06-22 | |
// Using Swift 5.0 | |
// | |
// Follow me on Twitter: @StewartLynch | |
// Subscribe on YouTube: https://youTube.com/StewartLynch | |
// | |
import SwiftUI |
This file contains hidden or 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
// is there a better way to do this? | |
// I want to be able to execute something after all of the items have printed | |
func doIt() { | |
let numItems = 3 | |
for item in 0...numItems { | |
DispatchQueue.main.asyncAfter(deadline: .now() + (Double(item) * 1)) { | |
print(item) | |
} | |
} |
This file contains hidden or 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
extension Bundle { | |
public func decode<T: Decodable>(_ type: T.Type, | |
from file: String, | |
dateDecodingStategy: JSONDecoder.DateDecodingStrategy = .deferredToDate, | |
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) -> T { | |
guard let url = self.url(forResource: file, withExtension: nil) else { | |
fatalError("Failed to locate \(file) in bundle.") | |
} | |
guard let data = try? Data(contentsOf: url) else { | |
fatalError("Failed to load \(file) from bundle.") |
This file contains hidden or 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
// | |
// Country.swift | |
// Country | |
// | |
// Created by Stewart Lynch on 2021-07-16. | |
// | |
import Foundation | |
struct Country: Identifiable { |
This file contains hidden or 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
class APIService { | |
static let shared = APIService() | |
enum APIError: Error { | |
case error(_ errorString: String) | |
} | |
func getJSON<T: Decodable>(urlString: String, | |
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate, | |
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
completion: @escaping (Result<T,APIError>) -> Void) { |
This file contains hidden or 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
// | |
// ContentView.swift | |
// OverlayDrag | |
// | |
// Created by Stewart Lynch on 2021-07-08. | |
// | |
import SwiftUI | |
struct ContentView: View { |