All Questions
Tagged with switch-statement ios
257
questions
1
vote
1
answer
33
views
Unique phrase for customer
I have function where I'm creating one of the cases randomly, but I want when I start the app It will only generate the message once and when I will open it again it will be the same but not different....
2
votes
0
answers
294
views
Swift / SwiftUI - State variable isn't updated inside switch statement?
I'm having trouble creating transitions that properly emulate iOS navigation transitions. Different transitions should play depending on whether the user is navigating "forward" or "...
0
votes
1
answer
73
views
Replace switch cases to reduce complexity
I wanted to replace switch cases with some other logic since it increases code complexity (CCN) on sonar.
enum ItemType {
case one, two, three, four, five, six, seven, eight, nine, ten
}
func ...
1
vote
2
answers
70
views
How to I cast a type to a variable in an enum within a switch statement?
switch error {
case Project.Client.LoadError.operationFailed(let error2):
switch error2 {
case Project.Client.APIClientError.invalidStatusCode(let message, _):
guard message != nil, ...
3
votes
3
answers
2k
views
SwiftUI Switch statement
How can I present in swiftUI a view in a switch case?
import Foundation
enum SideMenuViewModel: Int, CaseIterable, Decodable {
case Home
case Users
case TODOs
case AboutUs
...
0
votes
1
answer
633
views
Unable to check Switch cases with "null" value in swift
To check multiple conditions i am using switch statements
code: here all cases working fine but. if user_details?.rating = "" is empty then i need to show default case i mean all stars empty ...
-2
votes
1
answer
125
views
How to check "switch" statements with json data in swift
I need to check multiple if conditions in for loop so, i am not able to check like that so how to use switch statements with this below code
code: here how to turn below code into switch statements. ...
0
votes
2
answers
1k
views
Getting error : Expected expression in list of expressions
Can i not use switch to check for a variable and implement a view based on the variable's value. I tried using if else as well but still getting the same error. Do I have to create a method and return ...
1
vote
2
answers
58
views
Switch statement with closed-ranges covering full Float range
I am expecting the code below to cover the full Float range of which I use only a very small part just above 0.
My app however sometimes crashes in the field because it hits default: fatalError().
...
1
vote
2
answers
1k
views
How to show Text depends on switch case in SwiftUI?
I am working with SwiftUI, I have one switch case function, depend on that switch case i want to show diff color and text.
func status(status: Status){
switch status {
case ...
1
vote
3
answers
183
views
Refactor code for two switch case statement
I'm working on a swift project and have a question to refactor my code.
I'm writing code for checking if a user authorized both the camera and microphone authorization in the app. I wrote the ...
0
votes
1
answer
513
views
Swift • Can Enums have too many Cases?
I am working on a Swift App which uses an Enum. However, this Enum will have a bunch of cases. Maybe 1,000 or even more.
Code
enum Name: Int, CaseIterable {
case name1
case name2
case ...
2
votes
1
answer
156
views
How to connect enum/switch with an API value for a specific case swiftUI
I have a currency converter calculator application, Where data is fetched through the API. I am trying to convert inputted data through the enum and switch but unfortunately, I am not sure what is the ...
0
votes
0
answers
68
views
IOS Permission settings in a Switch case using c#
I am writing a switch case that will return a user friendly message to the user informing them what location permissions have been given to my IOS application (which completely relies on the location)....
1
vote
3
answers
532
views
can we override switch case behaviour like we override operator == with Equatable protocol in Swift
Equatable protocol not called when enum compared in switch case, how does it compare values?
I have implemented below Enum which works perfectly with If Conditions but fails in Switch case, how does ...