It's not that self->score.alpha is better than score.alpha—technically, it's the exact same code—it's that it makes it obvious that the block is implicitly retaining self.
This warning about implicit references to self is useful because in the absence of that, when glancing at code it isn't always obvious which blocks have the risk of introducing strong reference cycles and which don't.
if you're looking for Objective-C documentation, see Programming with Objective-C: Working with Blocks: Avoid Strong Reference Cycles when Capturing self.
Blocks can also take arguments and return values just like methods and functions.
Blocks Can Capture Values from the Enclosing Scope
the value is captured when the block is defined.
Only the value is captured, unless you specify otherwise.
the block cannot change the value of the original variable, or even the captured value (it’s captured as a const variable).
If you need to be able to change the value of a captured variable from within a block, you can use the 'block' storage type modifier on the original variable declaration. This means that the variable lives in storage that is shared between the lexical scope of the original variable and any blocks declared within that scope. It also means that the block can modify the original value.
You Can Pass Blocks as Arguments to Methods or Functions
Blocks are also used for callbacks, defining the code to be executed when a task completes.
A Block Should Always Be the Last Argument to a Method (best practice); because it makes the method call easier to read if it uses a literal as argument for the block.
Avoid Strong Reference Cycles when Capturing self. If you need to capture self in a block, such as when defining a callback block, it’s important to consider the memory management implications.
Blocks Can Simplify Concurrent Tasks
Last edit: Christa Runge 2020-06-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
See also svn r3929 and r3930 where more such warnings were intentionally introduced, but then the compiler warning was (temp) deactivated.
https://stackoverflow.com/questions/21577711/block-implicitly-retains-self-explicitly-mention-self-to-indicate-this-is-i
a few suggestions:
https://stackoverflow.com/questions/49582124/block-implicitly-retains-self-but-is-it-intended-behaviour?noredirect=1&lq=1
(https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW16)
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html#//apple_ref/doc/uid/TP40007502
Last edit: Christa Runge 2020-06-13
Apple docu - Working with blocks:
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW16
Last edit: Christa Runge 2020-06-13