Swift Struct Memory Leak

前端 未结 4 1883
轻奢々
轻奢々 2021-01-30 09:05

We\'re trying to use Swift structs where we can. We are also using RxSwift which has methods which take closures. When we have a struct that creates a closure that refers to

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 09:30

    The pattern of capturing self by an escaping closure in a writable context is now disallowed. The swift compiler will emit an error "Closure cannot implicitly capture a mutating self parameter". If the context is read-only, the value of self could be copied or shared and in either case there wouldn't be a reference cycle.

提交回复
热议问题