# Swift UI : Conditional view

**URL:** <https://forums.kodeco.com/t/swift-ui-conditional-view/122704>\
**Category:** Swift\
**Created:** [October 15, 2020, 9:36am UTC](https://forums.kodeco.com/t/swift-ui-conditional-view/122704 "2020-10-15T09:36:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luclannoo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/luclannoo/32/110937_2.png) [@luclannoo](https://forums.kodeco.com/u/luclannoo)\
**Post date:** [October 15, 2020, 9:36am UTC](https://forums.kodeco.com/t/swift-ui-conditional-view/122704/1 "2020-10-15T09:36:26Z")

</div>

**Swift UI refresh problem**

Defining a list of MenuItems in a View.  
I want to make a version where only the favorite MenuItems are displayed.  
Therefor I defined a bool for favorite selection.  
(Remark : I deleted all unneeded fields to make the problem clear)

Using the ObservedObject / Published wrappers

I see it working because the value of the switch is correctly updated in the view, but the line is not disapearing.

Models  
 ![Schermafbeelding 2020-10-15 om 11.23.26](https://files.chunter.kodeco.com/original/3X/7/6/767927cb74d2b73f002e6038c64aa7cf1cf2905d.png)

Views  
 ![Schermafbeelding 2020-10-15 om 11.28.42](https://files.chunter.kodeco.com/original/3X/3/6/3693080f8cc4f5782d2e0755619177bfb15d9e1c.png)

Initial state  
Filter works fine because on line 1 and 2 are shown.  
 ![image](https://files.chunter.kodeco.com/original/3X/1/d/1d2d266c2ef243dd913ae53237a105b5425dcf6c.png)

After update the list shows the wrong result : Line 1 should not be on the list.  
Favorite bool is on false =\> No Value

![Schermafbeelding 2020-10-15 om 11.22.17](https://files.chunter.kodeco.com/original/3X/d/b/dbc1c5e36f8840b59b5b30d800c0c93c49fdd8f8.png)

Xcode Version : 12.0.1  
Catalina Version : 10.15.6

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [March 31, 2021, 1:36am UTC](https://forums.kodeco.com/t/swift-ui-conditional-view/122704/2 "2021-03-31T01:36:27Z")

</div>

Closed on March 31, 2021, 1:36am UTC

This topic was automatically closed after 166 days. New replies are no longer allowed.
