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 | |
import SwiftUI | |
// SwiftUI | |
struct SomeView: View, HostingViewInitialization { | |
var body: some View { | |
Text("Hello World!") | |
} | |
} |
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 Foundation | |
extension CustomStringConvertible { | |
var description: String { | |
var description: String = "\(type(of: self))(" | |
let selfMirror = Mirror(reflecting: self) | |
for child in selfMirror.children { | |
if let propertyName = child.label { |
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 XCTest | |
class NotificationTestCase: XCTestCase { | |
func testTriggerNotification() { | |
expectation(forNotification: .fooBar, | |
object: nil, | |
handler: nil) | |
let notificationCenter = NotificationCenter.default |
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 PlaygroundSupport | |
import Foundation | |
struct Resource<A> { | |
var request: URLRequest | |
var parse: (Data) throws -> A | |
} | |
protocol Loadable { | |
static var request: URLRequest { get } |
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
func fetchResultsFromApi() { | |
struct MyGitHub: Codable { | |
let name: String? | |
let location: String? | |
let followers: Int? | |
let avatarUrl: URL? | |
let repos: Int? | |
private enum CodingKeys: String, CodingKey { |
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
//: Playground - noun: a place where people can play | |
// playing with dates | |
import Foundation | |
let date = Date() | |
let myLocale = Locale(identifier: "en_CA") | |
//: ### Setting an application-wide `TimeZone` | |
//: Notice how we use if-let in case the abbreviation is wrong. It will fallback to the default timezone in that case. |
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
a: AM/PM | |
A: 0~86399999 (Millisecond of Day) | |
c/cc: 1~7 (Day of Week) | |
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat | |
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday | |
d: 1~31 (0 padded Day of Month) | |
D: 1~366 (0 padded Day of Year) | |