View Visitor.swift
This file contains 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 Country { | |
func accept(visitor: CountryVisitor) | |
} | |
protocol CountryVisitor { | |
func visit(country: India) | |
func visit(country: Brazil) | |
func visit(country: China) | |
} |
View Template.swift
This file contains 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 Office { | |
func officeSchedule() | |
} | |
protocol Employee { | |
func work() | |
func getPaid() | |
} |
View Strategy.swift
This file contains 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 Strategy { | |
func convert(number: Int) | |
} | |
class Convert { | |
var strategy: Strategy | |
var number: Int | |
init(number: Int, strategy: Strategy) { |
View State.swift
This file contains 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 Human { | |
// MARK: - Getter | |
func getState() -> ManState | |
// MARK: - Setter | |
func set(state: ManState) | |
} | |
protocol ManState { | |
func stand() |
View Observer.swift
This file contains 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 Observable { | |
func add(customer: Observer) | |
func remove(customer : Observer) | |
func notify() | |
} | |
protocol Observer { | |
var id: Int { get set } | |
func update() |
View Memento.swift
This file contains 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 UIKit | |
typealias MementoType = [String: Any] | |
protocol Memento: class { | |
var key: String { get set } | |
var state: MementoType { get set } | |
func save() |
View Mediator.swift
This file contains 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 Receiver { | |
var name: String { get } | |
func receive(message: String) | |
} | |
protocol Sender { | |
var teams: [Receiver] { get set } | |
func send(message: String, sender: Receiver) | |
} |
View Iterator.swift
This file contains 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
struct MyBestFilms: Sequence { | |
let films: [String] | |
func makeIterator() -> MyBestFilmsIterator { | |
return MyBestFilmsIterator(films) | |
} | |
} | |
struct MyBestFilmsIterator: IteratorProtocol { |
View CommandDesignPattern.swift
This file contains 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 Command { | |
func execute() | |
} | |
class ConcreteCommand: Command { | |
var colorReceiver: ColorReceiver | |
init(colorReceiver: ColorReceiver) { | |
self.colorReceiver = colorReceiver |
View ChainOfResponsibility.swift
This file contains 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
enum Level: Int { | |
case state = 1 | |
case national = 2 | |
case international = 3 | |
} | |
class Sports { | |
var level: Level | |
NewerOlder