|
In my MacOS app MainView a define a NavigationView for my Students and Scores CoreData items as follows:
My StudentsView, for example, is as follows:
And its correspondant FilteredStudentsView:
As you can see, a typical navigationView-List outline. I'd like to keep selected item on StudentsView when I change to Works on MainView, and back again (and viceversa). Now doing so I find an empty detailed view until I select –again– one item from the list. I've tried with @Bindings and so, but haven´t found the correct way to make it work. Any suggestions? Thanks you all in advance. |
|
Hi, You should be able to do something like i did below, hopefully it works for you.
|
|
Thank you! Two comments about this. Solution suggested above by @Hectorcrdna really doesn't. It throws no error at all, but doesn't save/reveal last selected student after changing to another view. I tryed a very similar solution as suggested above by @Hectorcrdna, but with uuidString property os Students and .first property of Students array. This works! and both saves last selected item, and shows it when coming back to the view:
BUT now line marked throws an error on console, on run time, and app doesn't get displayed: Ignoring exception: Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. I supposse it's due to "forcing" the "instalation on the view" of that "constraint". That is: selecting the Student which holds that ID. I know the sentence "Does the constraint reference something from outside the subtree of the view?" is the clue to solve this issue, but I can't figure out exactly how. Any further suggestions? Thanks again! |
|
Where is |
|
Students is not really an array. It's:
Declared on this same view (I've modified references to clarify). This is due to the necesitty of initialiting my request each time with filterings:
Could it interfere with this? In fact, previously selected student could not be been displayed at all due to filterings change... mmm... |
|
Solved! :-) Just transforming fetchRequest to an array solved the problem:
Now everything working ok! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates.
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.