Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
-1 votes
0 answers
23 views

How to add a maximum character count for multiple textfields + a function to block certain characters from being entered in a text field swift

I have been trying to do two things: Have a maximum character limit for a few text fields. This is an issue because they are not all the same in terms of the maximum character numbers (one text field ...
Mous772's user avatar
  • 11
0 votes
1 answer
97 views

Type '(any Error)?' has no member 'success'

This is my create group function: webService.createGroup(url: apiUrl, requestBody: requestBody) { result in switch result { case .success(let response): print(...
AppleDev3's user avatar
0 votes
1 answer
21 views

Why will updateScore function in viewcontroller not call from gamescene

So I'm trying to make it so an ad will pop up every time the score in game scene reaches a certain point in my game in Xcode using Swift but it's not calling the function that does that(...
Sider the Programmer's user avatar
0 votes
0 answers
24 views

Carpool ID not fetching from my API properly

I am making a join group function that enables a user to join a group once they input in a join code. This is my api route: app.post('/api/joinGroup/:carpool_id', express.json(), async (req, res) =>...
AppleDev3's user avatar
0 votes
0 answers
36 views

I've managed to pass two-arguments function, where one-argument function is expected

func curry<A, B>(_ f: @escaping (A) -> B) -> (A) -> B { print("is called") return f } func sum(a: Int, b: Int) -> Int { a + b } curry(sum) It shouldn't even ...
Roman's user avatar
  • 1,485
-2 votes
1 answer
54 views

Why Fatal error: Unexpectedly found NIL while unwrapping an Optional value [closed]

I would like to read metadata from a video. The console shows me the creation date from the metadata of the file. I may be extracting the date (via string) incorrectly. Why do I get the fatal error? ...
CasyJones's user avatar
3 votes
2 answers
77 views

Understanding named vs positional function call in Swift

I'm encountering an issue with my code and I'm trying to understand why the initial call to add fails with a "Missing argument" error, while it runs successfully when passed to a different ...
Valencia's user avatar
  • 179
0 votes
3 answers
79 views

Swift - function that does add one or more enum values to an array

Having a struct dat has a variable that may contain a array of one or more enum values. I want with one function the possibility to add one or more enum values, like: mutating func addEnumValue(value: ...
iPadawan's user avatar
  • 1,042
0 votes
1 answer
174 views

Closure inside function / need explanation

I'm studying closures and saw a unknown (for me) example of the use of closures in function in the book: func counter() -> () -> Int { var count = 0 let incrementer: () -> Int = { ...
neuraldag's user avatar
0 votes
1 answer
59 views

Function Types Example Code / Need Explanation / Swift

I'm currently learning Swift function types and the book gives me such code to demonstrate how we can use variables with functions: var manipulateInteger: (Int, Int) -> Int func multNumber(_ first:...
neuraldag's user avatar
-1 votes
2 answers
54 views

How to use a string in a function name

I have these functions: private func chooseOfferButton1Tapped() { let vc = ChooseRdvVC() vc.offerCatched = arrayCatched![0] HapticsManager.shared.vibrate(for: .success) ...
JOHNY's user avatar
  • 41
0 votes
1 answer
148 views

Is there a performance penalty for creating a closure vs writing a function in swift?

Is there a performance penalty for creating and using a closure vs a normal function? See example below: using a closure: let array = [1, 2, 3] let doubler: (Int) -> Int = { $0 * 2 } array.map {...
serotonino's user avatar
0 votes
2 answers
58 views

Do you have an idea to improve my getRange() function in Swift?

I have a function getRange() that works very well with simple cases like Car(rent: []), Car(rent: [.Monday]) or Car(rent: [.Monday, .Tuesday]). import SwiftUI enum Days { case Monday, Tuesday, ...
Alexnnd's user avatar
  • 669
1 vote
2 answers
291 views

What is the difference between protocols as parameter or as generic type in Swift?

I'm pretty new in the iOS development world and I'm trying to understand protocols in Swift. Here's my code: protocol Animal { func printFood() } struct Rabbit: Animal { func printFood() { ...
Mia Sdev's user avatar
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

15 30 50 per page
1
2 3 4 5
87