To use NSTextList, you create a list style and apply it via a NSMutableParagraphStyle to the text range or typing attributes.
For dynamic updates:
For Selected Text: Modify the NSParagraphStyle of the selected range in the NSTextStorage.
For Typing Attributes: Update the typingAttributes of the NSTextView to ensure new text inherits the styles.
Avoid manual string attribute merging by working with the paragraph style directly.
Post
Replies
Boosts
Views
Activity
The Watch app might not show updates because the beta version on your Watch isn't compatible with the iPhone's current software.
You might need to unenroll the Watch from the beta program or contact Apple Support for help syncing the software versions.
Your issue is that URL(string:) expects a valid URL with a scheme (like file://), but you're passing a file path directly.
It is similar to the following error:ErrorDomain = NsCocoaErrorDomain & ErrorCode = 4
Instead, you should use URL(fileURLWithPath:) for file paths. Here's the fixed code:
var tempString = String()
for Rezept in alleRezepte {
tempString += "\(Rezept.name), \(Rezept.description), \(Rezept.nutrients), \(Rezept.whatToDo)\n"
}
if let dirs = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first {
let path = dirs.appending("/rezepte.csv")
let url = URL(fileURLWithPath: path)
do {
try tempString.write(to: url, atomically: true, encoding: .utf8)
print("Daten gesichert")
} catch {
print("Error saving file: \(error)")
}
}