Avatar
import UIKit class ViewController: UIViewController { let titleText = "title" func api(_ callback: @escaping () -> Void) { callback() } override func viewDidLoad() { super.viewDidLoad() api { [weak self] in guard let self else { return } Task { [self] in // ⚠️ Capture 'self' was never used print(titleText) // ❌ Reference to property 'titleText' in closure requires explicit use of 'self' to make capture semantics explicit } } } } (edited)
9:28 AM
確かにおもちさんの例みたいなexplicit captureは問題ないことが確認できました 🙏 自分の悩みは↑のケースがコケる原因がいまいち解釈できない感じです。