I’m kinda block for this scenario , I have a enum which have the same value now the question here is that they have different usecases how can I put a condition for this to case
in switch:
supposed I have this:
enum ApiType: String, CaseIterable {
case dashboard = "dashboardRootIdApi"
case profile = "profileRootIdApi"
case usemeInLogin = "authenticationAccessIdApi"
case usemeInLogout = "authenticationAccessIdApi"
}
and from my usecases classes:
func authenticationDtoScreen(for: ApiType) -> UIControllerSharedScreen {
switch myType {
case .usemeInLogin: {
return UIControllerScreenConfiguration(
for: .usemeInLogin,
title: "Login"
)
}
case .usemeInLogout: {
return UIControllerScreenConfiguration(
for: .usemeInLogout,
title: "Logout"
)
}
}
}
I know .usemeInLogout
will never be happend cause of this .usemeInLogin
.
2
Answers
Its a bit hard without context, but I’d suggest using simple enum for use case differentiation:
And if needed, have a map from this enum to String, like:
Those string values don’t have to be the raw value of your enum. It can be a calulated property: