Referencing `self` from within a VTCompressionOutputCallback [duplicate]
问题 This question already has answers here : How to use instance method as callback for function which takes only func or literal closure (2 answers) Closed 1 year ago . I'm currently trying to use VideoToolbox to encode video data from an AVCaptureVideoDataOutput , but I'm having an issue referencing self from within the VTCompressionOutputCallback . My code is as follows: ... var sessionRef: VTCompressionSession? let outputCallback: VTCompressionOutputCallback = { _, _, status, _, sampleBuffer