개발/swift

Swift What is Enumeration?

lemonade 2020. 11. 20. 10:00
반응형

What is Enumeration?

 

An enumeration is a data type consisting of a set of named values, called members. Apple doc says:

 

An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

 

An enumeration can be a string, a character, or integer or floating-point type.

 


How to define enum type?

1. Enum with type definition

 


2. Enum with no type definition

 

 


3. Enum can have function or variable

 


More surprisingly

Optionals type, which handles the absence of a value is enumeration!

 

 

 


Happy Coding :)

 

반응형
그리드형

'개발 > swift' 카테고리의 다른 글

Swift new feature in ios14, IDFA  (0) 2020.11.26
Swift How to detect screenshot action?  (0) 2020.11.22
Swift UIColorPickerViewController  (0) 2020.11.14
Swift UIControls with closures  (0) 2020.11.12
Swift URLComponents  (0) 2020.11.12