'self' captured by a closure before all members were initialized

前端 未结 3 2093
囚心锁ツ
囚心锁ツ 2020-12-11 01:02

Alright, so just to start off, heres my code:

import UIKit
import ForecastIO

class Weather {
    var temp: Float
    var condition: String
    var wind: Fl         


        
3条回答
  •  Happy的楠姐
    2020-12-11 01:42

    You have two options, declare the properties as optionals, or initialize them with a default value (this means they will be non-optionals)

    var temp: Float?
    var condition: String?
    var wind: Float?
    var precip: Float?
    

    or

    var temp: Float=0
    var condition: String=""
    var wind: Float=0
    var precip: Float=0
    

提交回复
热议问题