For most iteration blocks, signatures are defined sort of:
void(^)(id obj, BOOL* stop)
It looks better using return value for stopping flag.
BOOL(^)(id obj)
However I believe there is a strong reason made them to decide to use current form instead of more short and convenient form. Why do they use argument for stop flag?
Sure, it would work fine either way, but think of it this way: do you have to use the continue
statement at the end of your for
or while
loop? No, of course not because it happens automatically. If you want to stop looping though, you can just use break
.
Similarly with the block-based enumeration methods. You're not required to return YES
to specify whether you want to continue enumeration or not because it will happen automatically. However, if you want to stop enumerating, you can simply set *stop
to YES
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With