Post

Replies

Boosts

Views

Activity

Reply to [SwiftUI] When to use closures vs equals for variable assignment?
It is not a convention, it is a major difference. The difference is that computed var (first option) is evaluated each time the var is accessed. So it can change on the fly. The second option is initialised once for all. Consider the simple case: var myVar: Int { (0...10).randomElement()! } var myVar2 = (0...10).randomElement()! for _ in 0...3 { print(myVar, myVar2) } You get: 5 4 1 4 4 4 7 4
Jul ’24
Reply to Incorrect JSON Format with JSONEncoder
print(encoded) returns 110 bytes. When I test it with the following code, let account = AccountCreationData(name: "name", email: "email", phone: "phone", password: "password") if let encoded = try? JSONEncoder().encode(account) { print("encoded", encoded) print("content", String(data: encoded, encoding: .utf8)!) // To see the content of encoding } else { print("Failed to encode request") } I get encoded 69 bytes // (the string 'name: "name", email: "email", phone: "phone", password: "password"' is 66 bytes) content {"email":"email","password":"password","name":"name","phone":"phone"} Could you print the same log on your side ? And please show how you call createAccount. You may have a problem there. Also, why do you dispatch here: DispatchQueue.main.async { completion(resData) } } catch let jsonError as NSError {
Topic: App & System Services SubTopic: General Tags:
Jul ’24
Reply to App rejected as spam
Read the guidelines. Spam may be because your app falls into an overcrowded category without enough innovative features. Dating apps are just such a category. 4.3 Spam (b) Also avoid piling on to a category that is already saturated; the App Store has enough fart, burp, flashlight, fortune telling, dating, drinking games, and Kama Sutra apps, etc. already. We will reject these apps unless they provide a unique, high-quality experience. Spamming the store may lead to your removal from the Apple Developer Program. So, the only thing you can do is to add comments to reviewer explaining how your app provides this unique experience.
Jul ’24
Reply to Most efficient way to call a function upon variable state change
It would be much simpler to explain if you posted the code you have tried with Binding. Is it what you are looking for ? struct TestButton: View { @Binding var isSelected: Bool var body: some View { Button(action: { self.isSelected.toggle() }) { Text("Change") } } } struct ContentView: View { @State var buttonState = false @State var someTextToDisplay = "no state defined yet" func forStateOn() { someTextToDisplay = "State is on" } func forStateOff() { someTextToDisplay = "State is off" } var body: some View { VStack { Text(buttonState ? "selected" : "unselected") TestButton(isSelected: $buttonState) Text(someTextToDisplay) } .onChange(of: buttonState) { oldState, newState in if newState { forStateOn() } else { forStateOff() } } } }
Topic: Design SubTopic: General Tags:
Jul ’24
Reply to [SwiftUI] When to use closures vs equals for variable assignment?
It is not a convention, it is a major difference. The difference is that computed var (first option) is evaluated each time the var is accessed. So it can change on the fly. The second option is initialised once for all. Consider the simple case: var myVar: Int { (0...10).randomElement()! } var myVar2 = (0...10).randomElement()! for _ in 0...3 { print(myVar, myVar2) } You get: 5 4 1 4 4 4 7 4
Replies
Boosts
Views
Activity
Jul ’24
Reply to Incorrect JSON Format with JSONEncoder
print(encoded) returns 110 bytes. When I test it with the following code, let account = AccountCreationData(name: "name", email: "email", phone: "phone", password: "password") if let encoded = try? JSONEncoder().encode(account) { print("encoded", encoded) print("content", String(data: encoded, encoding: .utf8)!) // To see the content of encoding } else { print("Failed to encode request") } I get encoded 69 bytes // (the string 'name: "name", email: "email", phone: "phone", password: "password"' is 66 bytes) content {"email":"email","password":"password","name":"name","phone":"phone"} Could you print the same log on your side ? And please show how you call createAccount. You may have a problem there. Also, why do you dispatch here: DispatchQueue.main.async { completion(resData) } } catch let jsonError as NSError {
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to App rejected as spam
Read the guidelines. Spam may be because your app falls into an overcrowded category without enough innovative features. Dating apps are just such a category. 4.3 Spam (b) Also avoid piling on to a category that is already saturated; the App Store has enough fart, burp, flashlight, fortune telling, dating, drinking games, and Kama Sutra apps, etc. already. We will reject these apps unless they provide a unique, high-quality experience. Spamming the store may lead to your removal from the Apple Developer Program. So, the only thing you can do is to add comments to reviewer explaining how your app provides this unique experience.
Replies
Boosts
Views
Activity
Jul ’24
Reply to Unable to Display Text Fully in Text() SwiftUI
Effectively, it does not display the circle below g: Adding a baseline offset makes it work: struct ContentView: View { var body: some View { Text("[ɡ̠̥ɑʔ͡t]") .baselineOffset(10) .font(.title) .fontWeight(.semibold) .padding() } } I did the test with Xcode 16.0ß2.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to Most efficient way to call a function upon variable state change
It would be much simpler to explain if you posted the code you have tried with Binding. Is it what you are looking for ? struct TestButton: View { @Binding var isSelected: Bool var body: some View { Button(action: { self.isSelected.toggle() }) { Text("Change") } } } struct ContentView: View { @State var buttonState = false @State var someTextToDisplay = "no state defined yet" func forStateOn() { someTextToDisplay = "State is on" } func forStateOff() { someTextToDisplay = "State is off" } var body: some View { VStack { Text(buttonState ? "selected" : "unselected") TestButton(isSelected: $buttonState) Text(someTextToDisplay) } .onChange(of: buttonState) { oldState, newState in if newState { forStateOn() } else { forStateOff() } } } }
Topic: Design SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’24