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
| class Object { | |
| var anotherObject: AnotherObject | |
| } |
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
| class Object { | |
| var children: [Object] | |
| } |
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 Component { | |
| func foo() | |
| } | |
| class Composite: Component { | |
| var children: [Component] = [] | |
| func foo() { |
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
| // Generated interface for UIView.h in Swift 4 | |
| extension UIView { | |
| open var subviews: [UIView] { get } | |
| } |
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
| // Generated interface for UIViewController.h in Swift 4 | |
| extension UIViewController { | |
| @available(iOS 5.0, *) | |
| open var childViewControllers: [UIViewController] { get } | |
| } |
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 Task { | |
| func run(_ completion: @escaping (_ task: Task) -> Void) | |
| } |
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
| let tasks: [Task] = // List of concrete tasks |
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
| let group = DispatchGroup() | |
| for task in tasks { | |
| group.enter() | |
| task.run({ task in | |
| group.leave() | |
| }) | |
| } |
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
| class CompositeTask: Task { | |
| let tasks: [Task] | |
| init(_ tasks: [Task]) { | |
| self.tasks = tasks | |
| } | |
| func run(_ completion: @escaping (Task) -> Void) { | |
| let group = DispatchGroup() |
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
| let compositeTask = CompositeTask(tasks) | |
| compositeTask.run() { _ in | |
| print("All tasks completed") | |
| } |