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
| protocol Delegate: AnyObject { | |
| } | |
| class A { | |
| weak var delegate: Delegate? | |
| } | |
| class B: Delegate { | |
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
| func foo(_ completion: (Bool) -> Void) { | |
| completion(Bool.random()) | |
| } | |
| func bar() async -> Result<Bool, Never> { | |
| return await withCheckedContinuation { continuation in | |
| foo { result in | |
| continuation.resume(returning: .success(result)) | |
| } | |
| } |
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 | |
| class WindowBackedHelperView: NSView { | |
| var didMoveToWindow: (NSWindow) -> Void | |
| init(didMoveToWindow: @escaping (NSWindow) -> Void) { | |
| self.didMoveToWindow = didMoveToWindow | |
| super.init(frame: .zero) | |
| } | |