Avatar
↓で前者だと「actor-isolated property 'monsters' cannot be passed 'inout' to 'async' function call」のビルドエラーになるけど、後者のようにローカル変数に退避させたらビルドが通った monsters はプロパティ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { Task { await presenter.didSelectMonster(monster: monsters[indexPath.row]) } } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { Task { let monster = monsters[indexPath.row] await presenter.didSelectMonster(monster: monster) } }
8:01 AM
この修正方法でいいのかわからない、、
8:04 AM
あと async 関数を投げっぱなしにする方法あるのかな? 以下で interactor.saveForSpotlight() の実行を待たずに router.showMonsterDetail(monster: monster) を実行したい 処理の順番を逆にすればいけそうだけど、微妙な気がする func didSelectMonster(monster: MonsterEntity) async { await interactor.saveForSpotlight(monster) router.showMonsterDetail(monster: monster) }