|
i have a DocumentGroup app and some ui input or object modifications does not appear as "edited" beside the file name. means the FileDocument think it was not modified. TextEditor raised a "edited" TextField not ColorPicker not DatePicker not (macOS Xcode SwiftUI) |
|
seems i must replace @StateObject or @ObservedObject to @Binding. it is very difficult to replace this afterwards .. i have a few parts working and TextField show me that i edited the document in the title bar. i guess it will resolve other issues with input for date/color drag and drop in arrays too. edit: now it works half. if me add a column to a board.columns array via method board.addColumn() the view does not get a update :( it updates the views if me put the xcode ide in front and if me switch back to my app it looks ok. i have a data model with published properties. board,columns,cards each of them have a view BoardView, ColumnView, CardView. once i bind a color picker to the property but also set a random color into the card object itself. now with @Binding the color picker give me a edtited filedocument but via menu and method the color change card.randomColor() does nothing, it not reflect to ui anymore. |
|
can someone see my mistake here?
basic app code
|
|
Do you complete project 13 of HackingWithmacOS SwiftUI book ? I just start this project, you can see my code here : https://github.com/Sebastien-Remy/HackingwithmacOS-13-Screenable Hope it can help you @twothrow may be this post had to move to the macOs forum ? |
|
If you are going to use a class for your document, the class must conform to
There is very little documentation on |
|
Hi Markus One of the issues I see in your code is that you are using nearly everywhere reference (= If I were you, I went with plain value types (= Other issues I see in your code: You are using And a third issue: Never ever initialize an regards Philipp |
|
Here is my solution using just value types (based on your code).
It can be improved by using
|
|
thank you all for explanation and examples. :) yes it seems i must use structs and functions with mutating. another interesting template is the date planner from swift play ground. |
SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.