Post

Replies

Boosts

Views

Activity

Reply to Error Domain=NSCocoaErrorDomain Code=518 "The file couldn’t be saved because the specified URL type isn’t supported."
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)") } }
2w
Reply to How to create and manage nested List with NSTextList, NSAttributedString and UI/NSTextView
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.
2w