Unexpected Error

Hello everyone,
I was working on a Xcode playground, and unexpectedly it appeared an error that I can't understand how to fix. Here's the error that I'm facing.

Does someone know how to fix it?
Thanks in advance ;)

Answered by ssmith_c in 751369022

someone will be able to help you if you post the code itself, rather than a screenshot of a fragment of it (format it as code so it is readable).

It seems that you wrote an init() function that does nothing. In the struct or class which you are initializing, there are properties declared like this:

var whatever: String

or

var somethingElse: Float

for example

Either declare them with initial values

var whatever = "Hello"
var somethingElse = 1.0

or give them values in your init(), perhaps like this

init() {
    whatever = "goodbye"
    somethingElse = someThingComplicatedThatReturnsAFloat()
}
Accepted Answer

someone will be able to help you if you post the code itself, rather than a screenshot of a fragment of it (format it as code so it is readable).

It seems that you wrote an init() function that does nothing. In the struct or class which you are initializing, there are properties declared like this:

var whatever: String

or

var somethingElse: Float

for example

Either declare them with initial values

var whatever = "Hello"
var somethingElse = 1.0

or give them values in your init(), perhaps like this

init() {
    whatever = "goodbye"
    somethingElse = someThingComplicatedThatReturnsAFloat()
}

The init in SwiftUI may be tricky, if you have Binding var or State var…

In some cases, it is better to use .onAppear instead of an init().

So please show real full code so that someone can tell.

Ok thank you very much all ;))

Unexpected Error
 
 
Q