- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 78字
- 2021-07-02 14:45:15
Renaming classes
The first step would be to rename the classes and enums so they don't expose this ugly FV prefix:
typedef NS_ENUM(NSInteger, FVMeasureUnit) {
/* ... */
} NS_SWIFT_NAME(MeasureUnit); // notice the attribute is 'after'
// And for interfaces the attribute is before
NS_SWIFT_NAME(Measure)
@interface FVMeasure : NSObject
We can now rewrite our Swift to the following:
let measure = Measure(amount: 10, unit: MeasureUnit.cups)
The class and enum names are quite better but we can go further.
推薦閱讀
- 我們都是數據控:用大數據改變商業、生活和思維方式
- Access 2016數據庫教程(微課版·第2版)
- ETL數據整合與處理(Kettle)
- 復雜性思考:復雜性科學和計算模型(原書第2版)
- Learning JavaScriptMVC
- Creating Dynamic UIs with Android Fragments(Second Edition)
- 大數據技術入門
- 數據中心數字孿生應用實踐
- Flutter Projects
- SQL應用及誤區分析
- 貫通SQL Server 2008數據庫系統開發
- Oracle 11g+ASP.NET數據庫系統開發案例教程
- Deep Learning with R for Beginners
- 數據庫原理與設計實驗教程(MySQL版)
- 利用Python進行數據分析(原書第2版)