ARC with blocks and retain cycles

后端 未结 1 1561
醉酒成梦
醉酒成梦 2021-01-23 18:00

I have a class which holds a block as an object property:

@property (nonatomic, readwrite, copy) SFFailureBlock failureBlock;

where SFFailureBl

1条回答
  •  猫巷女王i
    2021-01-23 18:21

    When you refer to "failureBlock" in the operation's block, you are really doing "self-> failureBlock" - so it implicitly retains self. What you can do is create an automatic variable SFFailureBlock xFailureBlock = failureBlock; above the selfoperation, then use it in the block. [Again, you want to avoid any self-> references INSIDE that block either.]

    0 讨论(0)
提交回复
热议问题