|
Hello! I am creating my first Swift UI app which is really simple but there is one thing I can't figure out. I have two views: a main view which display a list of notes and a view of a note. I have two problems with my project, one is a cosmetic one and the other is prettty crucial.
I would really appreciate if you could review and let me know my mistakes. Here's the repository - https://github.com/AleksLip/NoteApp Thank you in advance! |
|
Aleks seeks help with
In this code snip below, you define Also you're telling SwiftUI to let views know when the array named I am not sure this object publishes notifications when you change the VALUES inside a single
|
|
Also, you may want to review this thread. I think it answers the same question you're asking. See -> Array of Observable Objects And this article from Sundell. See -> Taking Notes! |
|
Hi @Obelix! Thank you for your notes, it does make sense to change the name of the struct and variable in the class, it makes more sense. I have read the article you shared and it prompted me to think that my notes are not saved because I do not trigger the updateNotes function. First, I added a button and it did the trick:
Then I googled how to automatically save whenever there is a change in the view, and I changed it to this (ut went under "Form"):
Now when I navigate to any note I have just type somthing in, I can see the changes. But I still had the problem with the main view which had the list of the notes. The notes' title was still default unlike the title in the NoteView which would dynamically change based on the TextField value. I failed to figure out why until I realized I put the variable in the ForEach which would return a default value of "title". I changed it to "noteText" and the title became dynamic:
It is not what I need though, I would like each noteItem to update its "title" which my code can't do at the moment. I do think it has to be in the header section of the NoteView but I don't what exavtly to put there.
And I still have this problem:
|
|
Here are few note taking apps which you can opt for: pctechtest.com/20-best-note-taking-apps |
SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.