Skip to content

Instantly share code, notes, and snippets.

View mlavergn's full-sized avatar

Marc Lavergne mlavergn

View GitHub Profile
@mlavergn
mlavergn / ios13.swift
Created September 2, 2020 19:01
iOS13 Deprecations
// keyWindow
- UIApplication.shared.keyWindow
+ UIApplication.shared.windows.first { $0.isKeyWindow }
// alt via Scenes
- UIApplication.shared.keyWindow
+ UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.flatMap { $0.windows }.first { $0.isKeyWindow }
// statusBarFrame
- UIApplication.shared.statusBarFrame
@mlavergn
mlavergn / coderunner.swift
Created April 30, 2020 20:21
Swift CodeRunner Template
import Foundation
// long running code
while RunLoop.main.run(mode: .default, before: .distantFuture) {}
@mlavergn
mlavergn / playground.swift
Last active May 5, 2020 15:54
Swift Playground Template
import Foundation
import PlaygroundSupport
// long running code
PlaygroundPage.current.needsIndefiniteExecution = true
@mlavergn
mlavergn / SwiftC.swift
Created February 28, 2020 18:00
Swift C Direct Calls
// silgen allows you to call C functions without headers or bridges
// not to be used as a rulem but might have some interesting use cases
@_silgen_name("getpid") private func getpid() -> pid_t
print(getpid())
@mlavergn
mlavergn / swiftcombine.swift
Created November 21, 2019 02:21
Swift Combine demo with RxSwift commenting
import Foundation
import Combine
// register the observable name
extension Notification.Name {
static let DemoObservable = Notification.Name("DemoObservable")
}
// define the observable value type
struct DemoValue {