【发布时间】:2020-05-19 09:22:08
【问题描述】:
我有两个枚举表。在第一个中,我列出了第一部分的标题,在第二个中,我列出了第一部分的图标。 如何将它们组合成一个枚举
enum cellSectionOne:Int, CaseIterable
{
case cellOne
case cellTwo
var titleCellSectionOne:String
{
switch self {
case .cellOne:
return "cellOne"
case .cellTwo:
return "cellTwo"
}
}
}
enum cellIconSectionOne:Int, CaseIterable {
case cellOneIcon
case cellTwoIcon
var icon: UIImage {
switch self {
case .cellOneIcon:
return UIImage(named: "iconOne.png")!
case .cellTwoIcon:
return UIImage(named: "iconTwo.png")!
}
}
}
【问题讨论】:
标签: ios swift enums switch-statement