【发布时间】:2020-05-11 14:47:41
【问题描述】:
在完成获取数据时,我会收到一个数据项。我想将此项目附加到一个数组中,然后调用数据,我该怎么做?我如何告诉函数等到所有数据都附加到数组中 - 并且数据数量不同。
self?.dataModel.fetchExportCSV(id: id, completion: { [weak self] in
switch $0 {
case .success(let data):
var arryData: [exportVO] = []
arryData.append(data)
//this is the fucntion that should be called after all the data are append to the array
createCSV(data: arryData)
【问题讨论】:
-
使用
DispatchGroup或Semaphores -
你能给我举个例子吗
-
你是说你的完成处理程序被多次调用还是你多次调用
fetchExportCSV?
标签: ios arrays swift completionhandler