Avatar
Avatar
uhooi
↓で前者だと「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) } }
async関数を投げっぱなしにするのは、Task { }で囲むでいいと思います。
🙏 1