mirror of
https://github.com/jphong1111/awesome-ios-developer.git
synced 2024-12-22 22:05:44 +07:00
update delegation pattern
This commit is contained in:
parent
4f6900c32b
commit
930138f787
24
README.md
24
README.md
@ -193,9 +193,33 @@ class Adapter: Target {
|
||||
|
||||
## Delegation
|
||||
|
||||
Delegation is a design pattern that enables a class to hand off (or “delegate”) some of its responsibilities to an instance of another class.
|
||||
|
||||
### Example
|
||||
|
||||
Create a protocol
|
||||
|
||||
```swift
|
||||
protocol SomeProtocol {
|
||||
func reload()
|
||||
}
|
||||
```
|
||||
|
||||
Create a delegate
|
||||
```swift
|
||||
weak var delegate: SomeProtocol?
|
||||
```
|
||||
|
||||
|
||||
|
||||
You can check the code using delegation pattern [here]()
|
||||
|
||||
- [Delegation in Swift Swift by Sundell](https://www.swiftbysundell.com/articles/delegation-in-swift/)
|
||||
- [Delegation in Swift Explained](https://learnappmaking.com/delegation-swift-how-to/)
|
||||
- [Delegation Pattern in Swift 5.1](https://medium.com/@nimjea/delegation-pattern-in-swift-4-2-f6aca61f4bf5)
|
||||
|
||||
|
||||
|
||||
## Dependency Injection
|
||||
|
||||
Dependency injection is a pattern that can be used to eliminate the need for singletons in a project
|
||||
|
Loading…
Reference in New Issue
Block a user