mirror of
https://github.com/jphong1111/awesome-ios-developer.git
synced 2024-12-22 21:45:32 +07:00
Update README.md
This commit is contained in:
parent
aef75796de
commit
4f6900c32b
28
README.md
28
README.md
@ -163,6 +163,34 @@ Check [this](https://refactoring.guru/design-patterns/swift) website for design
|
||||
|
||||
## Adaptor
|
||||
|
||||
Adapter pattern is a structural design pattern that is useful for composing classes and objects into a larger system.
|
||||
|
||||
```swift
|
||||
protocol Target {
|
||||
func request()
|
||||
}
|
||||
|
||||
class Adaptee {
|
||||
func specificRequest() {}
|
||||
}
|
||||
|
||||
class Adapter: Target {
|
||||
let adaptee: Adaptee
|
||||
|
||||
init(adaptee: Adaptee) {
|
||||
self.adaptee = adaptee
|
||||
}
|
||||
|
||||
func request() {
|
||||
adaptee.specificRequest()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [‘Adapter’ Pattern in Swift](https://levelup.gitconnected.com/adapter-pattern-in-swift-b6403cfa0a78)
|
||||
- [Swift adapter design pattern](https://theswiftdev.com/swift-adapter-design-pattern/)
|
||||
- [Adapter in Swift](https://refactoring.guru/design-patterns/adapter/swift/example)
|
||||
|
||||
## Delegation
|
||||
|
||||
```swift
|
||||
|
Loading…
Reference in New Issue
Block a user