Post

Replies

Boosts

Views

Activity

Reply to Question about `UITextField`'s `markedTextRange` when handling Korean input
You should probably count for unicodeScalars.count, as described in Xcode doc about Character. Because each character in a string can be made up of one or more Unicode scalar values, the number of characters in a string may not match the length of the Unicode scalar value representation or the length of the string in a particular binary representation. print("Unicode scalar value count: \(greeting.unicodeScalars.count)") // Prints "Unicode scalar value count: 8" print("UTF-8 representation count: \(greeting.utf8.count)") // Prints "UTF-8 representation count: 11" So change to func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { guard let text = textField.text else { return true } return text.unicodeScalars.count <= 5 }
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’25
Reply to SwiftUI TextField corrupts selection when inserting utf16
I just tested with your new code and do not get the error. Log shows: input: changed from '' to '1' input: changed from '1' to '12' Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' input: changed from '12×' to '12×3' input: changed from '12×3' to '12×34' I run Xcode 16.4 on MacOS 15.5 (24F74) and iOS 18.4 simulator. Same with 18.5 simulator. Use hardware keyboard. With simulator virtual keyboard (on device simulator), log is different: input: changed from '' to '1' input: changed from '1' to '12' input: changed from '12' to '12*' input: changed from '12*' to '12*3' input: changed from '12*3' to '12*34' No more move log, and no change from * to x. So I added a print: func handleKeyPress(_ keyPress: KeyPress) -> KeyPress.Result { print(keyPress.key.character.unicodeScalars) if (keyPress.key.character == "*") { insertAtCursor(text: "×") moveCursor(offset: 1) return KeyPress.Result.handled } return KeyPress.Result.ignored } handleKeyPress is not called with virtual keyboard on simulator. But it is with the hardware keyboard: 1 input: changed from '' to '1' 2 input: changed from '1' to '12' * Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' 3 input: changed from '12×' to '12×3' 4 input: changed from '12×3' to '12×34' So I added another log: var body: some View { VStack { TextField("Type 12*34", text: $input, selection: $selection) .onKeyPress(action: {keyPress in print("onKeyPress", keyPress.key.character.unicodeScalars) return handleKeyPress(keyPress) }) .onChange(of: input) { oldValue, newValue in print("input: changed from '\(oldValue)' to '\(newValue)'") } Text("Selection: \(selectionAsString())") }.padding() } func handleKeyPress(_ keyPress: KeyPress) -> KeyPress.Result { print("handleKeyPress", keyPress.key.character.unicodeScalars) if (keyPress.key.character == "*") { insertAtCursor(text: "×") moveCursor(offset: 1) return KeyPress.Result.handled } return KeyPress.Result.ignored } With hardware keyboard, log is: onKeyPress 1 handleKeyPress 1 onKeyPress 2 handleKeyPress 2 input: changed from '' to '1' input: changed from '1' to '12' onKeyPress * handleKeyPress * Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' onKeyPress 3 handleKeyPress 3 input: changed from '12×' to '12×3' onKeyPress 4 handleKeyPress 4 input: changed from '12×3' to '12×34' with simulator virtual keyboard, log is: input: changed from '' to '1' input: changed from '1' to '12' input: changed from '12' to '12*' input: changed from '12*' to '12*3' input: changed from '12*3' to '12*34' Which shows onKeyPress is not called either. Surprising. But confirmed here: https://stackoverflow.com/questions/79198074/onkeypress-doesnt-work-on-textfield-foreach-array
Topic: UI Frameworks SubTopic: SwiftUI
Jun ’25
Reply to Having trouble posting
I once had a similar issue: https://developer.apple.com/forums/thread/779778 It seems the anti spam is oversensitive. You have to try and find the "offensive" word (in my case it was the word "f r e e" !) and adapt by adding spaces between the letters. Another way is to capture a screenshot of the prepared post, and attach the image ! Not exactly user friendly. And you could also post a bug report.
Jun ’25
Reply to Guideline 2.1 - Information Needed
Just one advice, hope that helps. Reviewer may be different at each review. So it may be useful to remind (concisely) what you describe here, in the Info to reviewer section so that he/she knows what you've done so far and doesn't think that this is a problematic app, just seeing you got several rejections..   another point: The reviewer likely didn’t notice that the country code is pre-filled and tried entering it manually So probably, some users will do the same error. Can you catch it and alert if user makes the mistake ?
Jun ’25
Reply to App Name capitalization issue
If it may help… I tested an app by changing the Bundle Display name to 1on1SimpleTest. And it displays correctly on iPhone (loaded from Xcode, not AppStore however). Also tested with a space: 1on1 Simple: display correctly. Note: if the name is too long, however, the space is removed: 1on1 SimpleTest 21 displays as 1on1SimpleTest 21
Jun ’25
Reply to Question about `UITextField`'s `markedTextRange` when handling Korean input
You should probably count for unicodeScalars.count, as described in Xcode doc about Character. Because each character in a string can be made up of one or more Unicode scalar values, the number of characters in a string may not match the length of the Unicode scalar value representation or the length of the string in a particular binary representation. print("Unicode scalar value count: \(greeting.unicodeScalars.count)") // Prints "Unicode scalar value count: 8" print("UTF-8 representation count: \(greeting.utf8.count)") // Prints "UTF-8 representation count: 11" So change to func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { guard let text = textField.text else { return true } return text.unicodeScalars.count <= 5 }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to SwiftUI TextField corrupts selection when inserting utf16
I just tested with your new code and do not get the error. Log shows: input: changed from '' to '1' input: changed from '1' to '12' Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' input: changed from '12×' to '12×3' input: changed from '12×3' to '12×34' I run Xcode 16.4 on MacOS 15.5 (24F74) and iOS 18.4 simulator. Same with 18.5 simulator. Use hardware keyboard. With simulator virtual keyboard (on device simulator), log is different: input: changed from '' to '1' input: changed from '1' to '12' input: changed from '12' to '12*' input: changed from '12*' to '12*3' input: changed from '12*3' to '12*34' No more move log, and no change from * to x. So I added a print: func handleKeyPress(_ keyPress: KeyPress) -> KeyPress.Result { print(keyPress.key.character.unicodeScalars) if (keyPress.key.character == "*") { insertAtCursor(text: "×") moveCursor(offset: 1) return KeyPress.Result.handled } return KeyPress.Result.ignored } handleKeyPress is not called with virtual keyboard on simulator. But it is with the hardware keyboard: 1 input: changed from '' to '1' 2 input: changed from '1' to '12' * Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' 3 input: changed from '12×' to '12×3' 4 input: changed from '12×3' to '12×34' So I added another log: var body: some View { VStack { TextField("Type 12*34", text: $input, selection: $selection) .onKeyPress(action: {keyPress in print("onKeyPress", keyPress.key.character.unicodeScalars) return handleKeyPress(keyPress) }) .onChange(of: input) { oldValue, newValue in print("input: changed from '\(oldValue)' to '\(newValue)'") } Text("Selection: \(selectionAsString())") }.padding() } func handleKeyPress(_ keyPress: KeyPress) -> KeyPress.Result { print("handleKeyPress", keyPress.key.character.unicodeScalars) if (keyPress.key.character == "*") { insertAtCursor(text: "×") moveCursor(offset: 1) return KeyPress.Result.handled } return KeyPress.Result.ignored } With hardware keyboard, log is: onKeyPress 1 handleKeyPress 1 onKeyPress 2 handleKeyPress 2 input: changed from '' to '1' input: changed from '1' to '12' onKeyPress * handleKeyPress * Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' onKeyPress 3 handleKeyPress 3 input: changed from '12×' to '12×3' onKeyPress 4 handleKeyPress 4 input: changed from '12×3' to '12×34' with simulator virtual keyboard, log is: input: changed from '' to '1' input: changed from '1' to '12' input: changed from '12' to '12*' input: changed from '12*' to '12*3' input: changed from '12*3' to '12*34' Which shows onKeyPress is not called either. Surprising. But confirmed here: https://stackoverflow.com/questions/79198074/onkeypress-doesnt-work-on-textfield-foreach-array
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jun ’25
Reply to Having trouble posting
I once had a similar issue: https://developer.apple.com/forums/thread/779778 It seems the anti spam is oversensitive. You have to try and find the "offensive" word (in my case it was the word "f r e e" !) and adapt by adding spaces between the letters. Another way is to capture a screenshot of the prepared post, and attach the image ! Not exactly user friendly. And you could also post a bug report.
Replies
Boosts
Views
Activity
Jun ’25
Reply to Guideline 2.1 - Information Needed
Just one advice, hope that helps. Reviewer may be different at each review. So it may be useful to remind (concisely) what you describe here, in the Info to reviewer section so that he/she knows what you've done so far and doesn't think that this is a problematic app, just seeing you got several rejections..   another point: The reviewer likely didn’t notice that the country code is pre-filled and tried entering it manually So probably, some users will do the same error. Can you catch it and alert if user makes the mistake ?
Replies
Boosts
Views
Activity
Jun ’25
Reply to App Name capitalization issue
If it may help… I tested an app by changing the Bundle Display name to 1on1SimpleTest. And it displays correctly on iPhone (loaded from Xcode, not AppStore however). Also tested with a space: 1on1 Simple: display correctly. Note: if the name is too long, however, the space is removed: 1on1 SimpleTest 21 displays as 1on1SimpleTest 21
Replies
Boosts
Views
Activity
Jun ’25