Post

Replies

Boosts

Views

Activity

Changing a character in String
This is what I've been doing to change a single letter at a specific location in a word:let word = "abc" var letters = Array(word.characters) letters[1] = "x" let newWord = String(letters)Surely there's a more elegant way in Swift 3. But is this really it?let index = word.index(word.startIndex, offsetBy: 1) let range = index ..< word.index(after: index) word.replacingCharacters(in: range, with: "x")It works; but it looks hideous.
4
0
2.7k
Oct ’16
Saving file to desktop from macOS app
I've been trying to save the output of a macOS app to my desktop. This is the code I'm using to do so:let homePath = FileManager.default.homeDirectoryForCurrentUser let desktopPath = homePath.appendingPathComponent("Desktop") print(desktopPath) let filePath = desktopPath.appendingPathComponent("TestFile.txt") do { try unicodeString.write(to: filePath, atomically: false, encoding: .utf8) } catch { errorMessage = error.localizedDescription + "\n" + unicodeString }And this is the error I get: You don’t have permission to save the file “TestFile.txt” in the folder “Desktop”.The path that's printed looks like this: file:///Users/DKJ/Library/Containers/com.hatzicware.FileCreator/Data/Desktopwhich of course is not on my desktop. How do I construct a path that will let me save the file?I get the same error running the app both in Xcode, and on its own in Finder.
6
0
7.1k
Aug ’19
App Store Connect Operation Error
Since updating to Xcode 11.0 yesterday, I've been unable to upload my app. The only error message I get is "App Store Connect Operation Error". Nothing else shows in the log.Previously (i.e. using Xcode 10) I uploaded several archives of this same app without any trouble. The current archive was created with Xcode 11, and validates without any complaints.Is anyone else having this problem at the moment? When I google about it, I see that it has occurred periodically in the past when Xcode has been updated.P.S. The error occurs consistently during the upload process, when Xcode is waiting for a response after sending API usage data.
12
0
8.3k
Sep ’19
Entering regular expression in TextField
I'm using a TextField in SwiftUI to enter regular expressions in an iOS app. But when I enter three dots (...) into the field, they are automatically converted to a single Unicode character. This does not create the regular expression I want to use. I've added .disableAutocorrection(true) to the text field, but the auto substitution still occurs. Is there some way I can prevent this from happening?
0
0
382
Oct ’21
App marked "removed from sale"
I removed my app from sale when Apple informed me it had to be updated. A few days ago I updated the app and submitted it for approval. It was approved shortly thereafter. On the App Store Connect page for the app, I clicked the Availability button for "All regions" and set the price to "Free". But 24 hours later, I'm still seeing "Removed from sale" displayed on that page. How can I get the app back on sale?
0
0
555
Sep ’22