Skip to content

Instantly share code, notes, and snippets.

View rslifka's full-sized avatar

Rob S. rslifka

View GitHub Profile
@rslifka
rslifka / inheritance.swift
Created October 23, 2021 17:59
Cannot declare conformance to 'NSObjectProtocol' in Swift
import AuthenticationServices
class Awesome: ASWebAuthenticationPresentationContextProviding {
// ERROR: Cannot declare conformance to 'NSObjectProtocol' in Swift
...
}
import Foundation
import AuthenticationServices
class Awesome: NSObject, ASWebAuthenticationPresentationContextProviding {
...
@rslifka
rslifka / anchor.swift
Last active October 23, 2021 16:27
Obtaining a reference to an ASPresentationAnchor for use with ASWebAuthenticationSession in SwiftUI
private var window: UIWindow {
guard
let scene = UIApplication.shared.connectedScenes.first,
let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate,
let window = windowSceneDelegate.window as? UIWindow
else {
return UIWindow()
}
return window