Instance member cannot be used on type | Closures

后端 未结 1 986
旧时难觅i
旧时难觅i 2021-01-17 03:49

I have a very simple NSViewController , which hits an API using a WeatherFetcher class. It passes a completion handler as a parameter, so that the

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 04:00

    You don't have access to the instance scope when initialising properties, you can only access the static context.

    Try this:

    var currentWeatherCallback: Weather? -> Void { return
        { (weather: Weather?) in
            self.currentTemp.stringValue = weather?.updatedTime
        }
    }
    

    0 讨论(0)
提交回复
热议问题