Long-time Swift dev here but haven't touched Objective-C in about ten years, so definitely rusty. Trying to figure out how to tell if a block parameter is escaping or not (i.e. so I know whether to use a weak ref or not as it isn't needed for non-escaping blocks.)
For instance, from what I've read, by default in Objective-C, block parameters are implicitly escaping (which is the opposite of Swift BTW.) If you don't want that, you have to use the NS_NOESCAPE
annotation, like so...
- (void)executeActions:(void (NS_NOESCAPE ^)(void))actions;
However, the enumerateObjectsUsingBlock
function I'm told is non-escaping, yet I don't see that annotation on the method in Apple's documentation. Actually, they don't talk about escaping or non-escaping at all. They just list the method.
Again, here's the documentation.
I then tried to search out the header file. I came across NSArray.h
which does mention it, but there too I don't see NS_NOESCAPE
.
https://github.com/.../NSArray.h (Line 79)
(I think this may be a generated/scraped page so maybe that information wouldn't be found here and you need the original headers. Not sure. Again, rusty.)
So how can one determine if a method's block parameters are escaping or not?