Instance member cannot be used on type | Closures

后端 未结 1 967
旧时难觅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)
提交回复
热议问题