🎃
Swift シンプルな完了をコールバックするクロージャを書く(引数あり)
呼び出す側の処理
dataManager.changeCategoryName(targetCategoryName: model.isSelectedTargetCategoryName,
changedCategoryName: changedText) {
DispatchQueue.main.async {
model.getCategoryFilterdDeckList()
let folderListView = self.view as! FolderListView
folderListView.tableView.reloadData()
}
}
呼び出される側の処理
func changeCategoryName(targetCategoryName:String,
changedCategoryName:String,
finished: @escaping () -> ()) {
for (index,targetDeck) in self.deckList.enumerated() {
if (targetDeck.folderName == targetCategoryName) {
targetDeck.folderName = changedCategoryName
}
}
finished()
}
Discussion