Check Mobile App
Read now
Start a Project

Enum with Localized String in Swift

Save

Nowadays we feel much comfortable using Enum when apple gives CaseIterable protocol through which we can iterate enum cases like an Array. How to use CaseIterable protocol with a raw value:-

Get an array of all cases:-

Many of the times we needed to use the raw value as display strings on labels and buttons etc. If the app contains localization it makes difficult to deal with actual localized string in enum cases and for we¬†write multiple strings lines of code again and again. if we directly localized the raw value then gets an error “Raw value for enum case must be a literal”

so have just take a look deal with localized raw value:-

How to use them:-

I hope from this, it will make you more comfortable dealing with Localized String of enum. Thanks for tuning in once again!

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Osama
Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home