【发布时间】:2018-10-20 05:14:17
【问题描述】:
假设我有一个字符串数组,并且我调用了一个从它返回一个 int 的异步方法。我想知道我的 int 数组中什么时候有这些 int 值。
let rndStrings = ["a", "b", "c"]
var rndInts = [Int]()
rndStrings.forEach { rndString in
someAsyncMethod { intResult in
rndInts.append(intResult)
}
}
我想等到 rndInts 拥有所有 3 个值
【问题讨论】:
-
我不确定,但是如果您想知道您的数组何时更改,您可以使用
Property Observers,也许,每次您制作时都会调用更改您的数组,这意味着在初始化时也是如此!
标签: swift