A question about _ _ block

problem description

using the constructor with block, there is a warning at compile time:


:Variable "pointsRuleView" is uninitialized when captured by block



what I want to ask is: what exactly is _ _ block doing here?

complete code: https://github.com/CaiWanFeng...


you need to know the capture rules of block. The following is a brief introduction, which may not be very accurate, but it is probably good to understand it.
in the first case, when block captures pointsRuleView, the value of pointsRuleView is not defined, and block may capture nil, so the compiler will give you a warning.
in the second case, the _ _ block keyword is added in the case of arc. It can be understood simply that if pointsRuleView is promoted from a local variable to a global variable, the pointsRuleView value in block can be obtained normally.
the above is just a simplified answer. For more information, please refer to books such as ios Advanced to understand the implementation details of block.