待处理

Swift-enum

2020-11-18  本文已影响0人  守护地中海的花

OC

typedef NS_ENUM(NSUInteger, APPCustomTabBarClickType) {
    APPCustomTabBarHomePage,
    APPCustomTabBarActivityPage,
    APPCustomTabBarCartPage,
    APPCustomTabBarMinePage,
};

Swift

enum Direction {
    case north
    case south
    case east,west
}
var dir = Direction.west
dir = Direction.east
dir = .north;
print(dir)

原始值 Raw Values

enum PokerSuit :Character {
    case spade = "🖤"
    case heart = "♥️"
    case diamond = "♦️"
    case club = "♣️"
}
var suit = PokerSuit.spade
print(suit,suit.rawValue)

隐式原始值 Implicitly Assigned Raw Values

递归枚举 Recursive Enumeration

后面搞

MemoryLayout

CaseIterable

enum PokerSuit :Character,CaseIterable {
    case spade = "🖤"
    case heart = "♥️"
    case diamond = "♦️"
    case club = "♣️"
}
let pokers = PokerSuit.allCases
for i in pokers {
    print(i)
}
上一篇 下一篇

猜你喜欢

热点阅读