- Swift 4 Programming Cookbook
- Keith Moon
- 96字
- 2021-07-08 10:21:30
How to do it...
In the last recipe, we added a method to our Person class to save it to a remote database. This is a very useful functionality, and as we add more and more features to our app, we will likely have more types where we will want to save instances of that type to a remote database. Let's create a protocol to define how we will interface with anything that can be saved in this way:
protocol Saveable {
var saveNeeded: Bool { get set }
func saveToRemoteDatabase(handler: @escaping (Bool) -> Void)
}
推薦閱讀
- 計(jì)算機(jī)網(wǎng)絡(luò)
- Mastering AWS Lambda
- Python從菜鳥(niǎo)到高手(第2版)
- Scratch 3游戲與人工智能編程完全自學(xué)教程
- 編譯系統(tǒng)透視:圖解編譯原理
- Visual Basic程序設(shè)計(jì)與應(yīng)用實(shí)踐教程
- 高級(jí)語(yǔ)言程序設(shè)計(jì)(C語(yǔ)言版):基于計(jì)算思維能力培養(yǎng)
- Scientific Computing with Scala
- 嵌入式Linux C語(yǔ)言程序設(shè)計(jì)基礎(chǔ)教程
- Mastering PowerCLI
- Laravel Design Patterns and Best Practices
- 每個(gè)人的Python:數(shù)學(xué)、算法和游戲編程訓(xùn)練營(yíng)
- Mastering React Test:Driven Development
- Java無(wú)難事:詳解Java編程核心思想與技術(shù)
- 代碼整潔之道:程序員的職業(yè)素養(yǎng)