Cannot invoke initializer for type ‘Double’ with an argument list of type ‘(Any)’

Hello everybody

 

i made an app to show the grades on my main screen. but i need the average of the three grades. I’m getting this error with the code: “Cannot invoke initializer for type ‘Double’ with an argument list of type ‘(Any)’ “

 

Does someone know how to solve it

 

 

@IBAction func aktualisieren(_ sender: Any) {

    

        let sprachennote_deutsch = UserDefaults.standard.object(forKey: “notenoutput_d”)

        let sprachennote_englisch = UserDefaults.standard.object(forKey: “notenoutput_e”)

        let sprachennote_franzoesisch = UserDefaults.standard.object(forKey: “notenoutput_f”)

    

        let sprache_d = Double(sprachennote_deutsch!) ?? 0.0

        let sprache_e = Double(sprachennote_englisch!) ?? 0.0

        let sprache_f = Double(sprachennote_franzoesisch!) ?? 0.0

    

        var arrayofgrades: [Double] = []

    

        if sprachennote_deutsch != “” { arrayofgrades.append(sprache_d)}

        if sprachennote_englisch != “” { arrayofgrades.append(sprache_e)}

        if sprachennote_franzoesisch != “” { arrayofgrades.append(sprache_f)}

    

        let sprachenschnitt = ((2 * sprache_d) + sprache_e + sprache_f) / 3

    

        sprachendurchschnitt.text = sprachenschnitt

        }

Powered by WPeMatico

About

You may also like...

Comments are closed.