【发布时间】:2017-04-03 13:57:56
【问题描述】:
我有一个函数,getSemainesStages(),它读取一个远程 json 文件并将结果放入(全局范围)数组中。
问题是它是异步的,就像有人向我解释的那样,我需要这个数组来填充 pickerView 数据源。
所以当我打电话时:
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return lesSemaines.count
}
数组还是空的,对于
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return lesSemaines[row]
}
只有在我的 getSemainesStages() 函数为空后,我才能做到这一点?
【问题讨论】:
-
在发布问题之前,请不要问多个问题for one topic 和search。