Advanced and Practical Enum usage in Swift

UIKit Identifiers

released Fri, 01 Mar 2019
Swift Version 5.0

UIKit Identifiers

Enums can be used to map reuse identifiers or storyboard identifiers from stringly typed information to something the type checker can understand. Imagine a UITableView with different prototype cells:

enum CellType: String {

     case buttonValueCell = \"ButtonValueCell\"

     case unitEditCell = \"UnitEditCell\"

     case labelCell = \"LabelCell\"

     case resultLabelCell = \"ResultLabelCell\"

}