Skip to content
Merged
2 changes: 1 addition & 1 deletion Sources/Bridge/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import XCTest

/// EN: The Abstraction defines the interface for the "control" part of the two
/// class hierarchies. It maintains a reference to an object of the
/// class hierarchies. It holds a reference to an object from the
/// Implementation hierarchy and delegates all of the real work to this object.
///
/// RU: Абстракция устанавливает интерфейс для «управляющей» части двух иерархий
Expand Down
2 changes: 1 addition & 1 deletion Sources/ChainOfResponsibility/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import XCTest
///
/// RU: Интерфейс Обработчика объявляет метод построения цепочки обработчиков.
/// Он также объявляет метод для выполнения запроса.
protocol Handler: class {
protocol Handler: AnyObject {

@discardableResult
func setNext(handler: Handler) -> Handler
Expand Down
8 changes: 4 additions & 4 deletions Sources/Command/RealWorld/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import XCTest


class DelayedOperation: Operation {
class DelayedOperation: Operation, @unchecked Sendable {

private var delay: TimeInterval

Expand Down Expand Up @@ -58,7 +58,7 @@ class DelayedOperation: Operation {
}
}

class WindowOperation: DelayedOperation {
class WindowOperation: DelayedOperation, @unchecked Sendable {

override func main() {
print("\(self): Windows are closed via HomeKit.")
Expand All @@ -67,7 +67,7 @@ class WindowOperation: DelayedOperation {
override var description: String { return "WindowOperation" }
}

class DoorOperation: DelayedOperation {
class DoorOperation: DelayedOperation, @unchecked Sendable {

override func main() {
print("\(self): Doors are closed via HomeKit.")
Expand All @@ -76,7 +76,7 @@ class DoorOperation: DelayedOperation {
override var description: String { return "DoorOperation" }
}

class TaxiOperation: DelayedOperation {
class TaxiOperation: DelayedOperation, @unchecked Sendable {

override func main() {
print("\(self): Taxi is ordered via Uber")
Expand Down
8 changes: 4 additions & 4 deletions Sources/Facade/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class Facade {
class Subsystem1 {

func operation1() -> String {
return "Sybsystem1: Ready!\n"
return "Subsystem1: Ready!\n"
}

// ...

func operationN() -> String {
return "Sybsystem1: Go!\n"
return "Subsystem1: Go!\n"
}
}

Expand All @@ -82,13 +82,13 @@ class Subsystem1 {
class Subsystem2 {

func operation1() -> String {
return "Sybsystem2: Get ready!\n"
return "Subsystem2: Get ready!\n"
}

// ...

func operationZ() -> String {
return "Sybsystem2: Fire!\n"
return "Subsystem2: Fire!\n"
}
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Facade/RealWorld/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FacadeRealWorld: XCTestCase {
/// In the real project, you probably will use third-party libraries. For
/// instance, to download images.
///
/// Therefore, facade and wrapping it is a good way to use a third party API
/// Therefore, facade and wrapping it is a good way to use a third-party API
/// in the client code. Even if it is your own library that is connected to
/// a project.
///
Expand All @@ -24,7 +24,7 @@ class FacadeRealWorld: XCTestCase {
/// fits most client needs. Moreover, it can set frequently used or default
/// parameters.

func testFacedeRealWorld() {
func testFacadeRealWorld() {

let imageView = UIImageView()

Expand All @@ -46,7 +46,7 @@ class FacadeRealWorld: XCTestCase {

private extension UIImageView {

/// This extension plays a facede role.
/// This extension plays a facade role.

func downloadImage(at url: URL?) {

Expand All @@ -68,7 +68,7 @@ private extension UIImageView {

private class ImageDownloader {

/// Third party library or your own solution (subsystem)
/// Third-party library or your own solution (subsystem)

typealias Completion = (UIImage, Error?) -> ()
typealias Progress = (Int, Int) -> ()
Expand Down
2 changes: 1 addition & 1 deletion Sources/FactoryMethod/RealWorld/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private class ClientCode {

func present(info: String, with factory: ProjectorFactory) {

/// Check wheater a client code already present smth...
/// Check whether the client code is already presenting something...

guard let projector = currentProjector else {

Expand Down
2 changes: 1 addition & 1 deletion Sources/Flyweight/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Flyweight {
}

func operation(uniqueState: [String]) {
print("Flyweight: Displaying shared (\(sharedState)) and unique (\(uniqueState) state.\n")
print("Flyweight: Displaying shared (\(sharedState)) and unique (\(uniqueState)) state.\n")
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Flyweight/RealWorld/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FlyweightRealWorld: XCTestCase {

/// Displaying objects for the 2-nd time.
///
/// Note: Cached object of the appearance will be reused this time.
/// Note: The cached appearance object will be reused this time.

print("\nClient: I have a new dog, let's show it the same way!\n")

Expand Down Expand Up @@ -93,7 +93,7 @@ struct Animal: Equatable {

struct Appearance: Equatable {

/// This object contains a predefined appearance of every cell
/// This object contains the predefined appearance for each cell.

let photos: [UIImage]
let backgroundColor: UIColor
Expand Down
4 changes: 2 additions & 2 deletions Sources/Iterator/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// - The `AnyIterator<Element>` struct provides basic iterator implementation:
/// https://developer.apple.com/documentation/swift/anyiterator
///
/// In this examples we'll see how to use both of these mechanisms.
/// In this example, we'll see how to use both of these mechanisms.
///
/// RU: Паттерн Итератор
///
Expand All @@ -32,7 +32,7 @@
import XCTest

/// EN: This is a collection that we're going to iterate through using an
/// iterator derived from IteratorProtocol.
/// iterator that conforms to IteratorProtocol.
///
/// RU: Это коллекция, которую мы будем перебирать используя итератор,
/// реализующий IteratorProtocol.
Expand Down
8 changes: 4 additions & 4 deletions Sources/Iterator/RealWorld/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class Tree<T> {

private func preOrder(_ body: Block) {
body(value)
left?.inOrder(body)
right?.inOrder(body)
left?.preOrder(body)
right?.preOrder(body)
}

private func postOrder(_ body: Block) {
left?.inOrder(body)
right?.inOrder(body)
left?.postOrder(body)
right?.postOrder(body)
body(value)
}
}
2 changes: 1 addition & 1 deletion Sources/Observer/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Subject {
///
/// RU: Наблюдатель объявляет метод уведомления, который используют издатели для
/// оповещения.
protocol Observer: class {
protocol Observer: AnyObject {

func update(subject: Subject)
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/Singleton/RealWorld/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class SingletonRealWorld: XCTestCase {
class BaseVC: UIViewController, MessageSubscriber {

func accept(new messages: [Message]) {
/// handle new messages in the base class
/// Handles new messages in the base class
}

func accept(removed messages: [Message]) {
/// handle removed messages in the base class
/// Hanldes removed messages in the base class
}

func startReceiveMessages() {
Expand All @@ -60,12 +60,12 @@ class MessagesListVC: BaseVC {

override func accept(new messages: [Message]) {
print("MessagesListVC accepted 'new messages'")
/// handle new messages in the child class
/// Handles new messages in the child class
}

override func accept(removed messages: [Message]) {
print("MessagesListVC accepted 'removed messages'")
/// handle removed messages in the child class
/// Handles removed messages in the child class
}

override func startReceiveMessages() {
Expand All @@ -78,12 +78,12 @@ class ChatVC: BaseVC {

override func accept(new messages: [Message]) {
print("ChatVC accepted 'new messages'")
/// handle new messages in the child class
/// Handles new messages in the child class
}

override func accept(removed messages: [Message]) {
print("ChatVC accepted 'removed messages'")
/// handle removed messages in the child class
/// Handles removed messages in the child class
}

override func startReceiveMessages() {
Expand Down
2 changes: 1 addition & 1 deletion Sources/State/Conceptual/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Context {
/// Конкретные Состояния, а также предоставляет обратную ссылку на объект
/// Контекст, связанный с Состоянием. Эта обратная ссылка может использоваться
/// Состояниями для передачи Контекста другому Состоянию.
protocol State: class {
protocol State: AnyObject {

func update(context: Context)

Expand Down