emum City{
case Beijing = 0,Shanghai,Guangzhou
static let allValues = [Beijing Shanghai,Guangzhou]
}
遍历:
for city in City.allValues{
print(city)
}
显示枚举名称对应的字符串:
let city = City.Beijing
let beijing ="\(city)"
print(beijing)
emum City{
case Beijing = 0,Shanghai,Guangzhou
static let allValues = [Beijing Shanghai,Guangzhou]
}
遍历:
for city in City.allValues{
print(city)
}
显示枚举名称对应的字符串:
let city = City.Beijing
let beijing ="\(city)"
print(beijing)
本文标题:Swift中枚举类型的遍历与显示
本文链接:https://www.haomeiwen.com/subject/keazlttx.html
网友评论