Skip to main content

All Questions

Tagged with
0 votes
2 answers
102 views

I need some help for the logic of a small SwiftUI view

I have a view with 3 switches and 1 button. At first, all the switches are false and you can only make one true. Also, the button only works if there's a difference between customOption and ...
Alexnnd's user avatar
  • 669
-1 votes
1 answer
57 views

Swift switch case let syntax - access function defined on nested enum [closed]

I need to access a function defined on a nested enum. My setup is the following: var currentlyShowingStepIndex:Int? var allSetupSteps:[SetupStep] = [] enum SetupStep { case districtSetupStep(...
Alex Ritter's user avatar
  • 1,031
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....
Mário Markovič's user avatar
2 votes
0 answers
201 views

swift - how can i use #available inside a switch statement

How can I use #available in a swift switch statement? Here is some sample code but of course I would like it to use in iOS too. Or if #available is not useable here what could I use? private func ...
iPadawan's user avatar
  • 1,042
-1 votes
2 answers
72 views

Swift/SwiftUI First update of a @State variable not received correctly

I am getting some weird behaviour from a switch statement in my SwiftUI view. In this view, when chosenParamsIndex is first updated to a value other than its initialising value (from a selection made ...
Flynn 's user avatar
  • 111
0 votes
1 answer
44 views

How to find all places in a project, where overridden ~= is used?

extension String { static func ~= (lhs: String, rhs: String) -> Bool { guard let regex = try? NSRegularExpression(pattern: rhs) else { return false } let range = NSRange(...
Roman's user avatar
  • 1,485
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 "...
George B's user avatar
  • 938
-1 votes
1 answer
245 views

How to integrate a switch statement in Swift UI? Where should it go in the document?

I get an error with the following on the line where my switch statement starts. I am completely new to Swift UI and lost at times on where some logic should go. In short I have two pickers and I want ...
Olasko's user avatar
  • 3
0 votes
1 answer
518 views

How to make switch case button in swiftUI with action and title

I want to make a button list with different actions in the switch case method in swiftUI. struct dashboard: View{ var categoriesText = ["My Orders", "Payments", "...
ashvinay's user avatar
7 votes
2 answers
1k views

How to use Swift literal regex expressions in switch case pattern statements?

How to use Swift literal regex expressions in switch case pattern statements? Based on the examples from WWDC 2022 presention slides, the following is expected to compile and run OK: import Foundation ...
marc-medley's user avatar
  • 9,574
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 ...
iOSDude's user avatar
  • 284
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, ...
Phillip's user avatar
  • 13
0 votes
1 answer
73 views

numberOfRowsInSection if inside Switch

I have this numberOfRowsInSection. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { switch Section(rawValue: section)! { case .slider: ...
Mert Köksal's user avatar
1 vote
2 answers
913 views

Swift tuple pattern matching fail to compile only for switch statement

I have the following struct: struct Pair<First, Second> { var first: First var second: Second static func ~= (pattern: (First, Second), value: Pair) -> Bool { /* code */ } } Now,...
funct7's user avatar
  • 3,529
-1 votes
2 answers
149 views

How to count how many types in array[Any]

I am new to Swift so im just trying to solve basic problems, but can't figure out this one. I am trying to count how many times a String, Int, Double or another class appears. And output the data. ...
camid's user avatar
  • 9

15 30 50 per page
1
2 3 4 5
31