Answers for "Saving file to desktop from macOS app"

0

Saving file to desktop from macOS app

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
}
Posted by: Guest on June-15-2021

Browse Popular Code Answers by Language