Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
Help: Creating a menu - Result of 'ContentView' initializer is unused
Post Flair (click to view more posts with a particular flair)
Post Body

Hi there, A bit of a newbie Swift UI coder here.

I’m really enjoying playing around in building an app in Playgrounds.

I have the basic mechanism of the main game mostly worked out.

The trouble I’m having is that when the app runs, I have a splash screen, followed by a menu page (not sure if I’m using the word page correctly for Swift).

I want to make it that when the Play button on the menu page is touched, that the user is taken to a new window (view I assume), where I have a view that contains all the main game.

When I try call this view by simply putting the following in the buttons action, I get a warning that “Result of 'ContentView' initializer is unused”

    ContentView() 

https://preview.redd.it/wcyu54chbcab1.jpg?width=2385&format=pjpg&auto=webp&s=bffa5e654363ef1ec337949aec2e1e4dbb7c1731

I am so confused how to bring in the ContentView. Any help would be greatly appreciated. I am working my way through 100 days, but I’m also looking around at videos online to see if I can solve this issue in some way.

Am I perhaps not thinking about how views work in SwiftUI?

Or is it because I’m coding only in Swift Playground?

Should I be nesting my splash view, menu view and game view in a NavigationView and then I can call these views when needed?

Also I currently have the ContentView() as a separate swift file but in the same app in Playground, would that be causing the problem?

Any help is greatly appreciated, really feeling like I’m finding this way harder than it should be.

Author
Account Strength
100%
Account Age
8 years
Verified Email
Yes
Verified Flair
No
Total Karma
6,495
Link Karma
1,439
Comment Karma
4,888
Profile updated: 1 day ago
Posts updated: 4 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago