Skip to content

Instantly share code, notes, and snippets.

View Jack-Adam-Mwanzo's full-sized avatar
🤖
Send me smt

Jack-Adam-Mwanzo

🤖
Send me smt
View GitHub Profile
@marslin1220
marslin1220 / RequestPlayground.swift
Last active September 4, 2024 13:52
How to create a HTTP GET request on Swift Playground
import Foundation
import PlaygroundSupport
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
PlaygroundPage.current.needsIndefiniteExecution = true
// Refer to the example: https://grokswift.com/simple-rest-with-swift/
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todo/1"
guard let url = URL(string: todoEndpoint) else {
print("Error: cannot create URL")
@jimbrayrcp
jimbrayrcp / Text Field Character Count.swift
Created June 10, 2020 19:18
For Swift UI: a simple text field character counter with return value into another text field.
import SwiftUI
import Combine
class TextCountMgr: ObservableObject {
@Published var counted = "0"
@Published var text = "" {
didSet {
counted = String(text.count)
}