Highly intelligent iOS developers use enum with properties. Don’t make your code seem dull.

Define Enum and its properties

enum with properties

Using with CaseIterable

Now Menu conforms to CaseIterable
let menus: [Menu] = [.coffee, .bread]
let menus: [Menu] = [Menu(title: "Coffee", price: 6.5, origin: "Ethiophia", calories: 5.0), Menu(title: "Bread", price: 3.5, origin: "Ukraine", calories: 120)]

My another usecase

View with same structure but with different image and title
My Code
MySomeDialogView(type: .charge)

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KD Knowledge Diet

KD Knowledge Diet

2.4K Followers

Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!