Double pointer as Objective-C block parameter
Posted
by
George WS
on Stack Overflow
See other posts from Stack Overflow
or by George WS
Published on 2013-10-21T21:20:29Z
Indexed on
2013/10/21
21:53 UTC
Read the original article
Hit count: 359
objective-c
|objective-c-blocks
Is it possible (and if so, safe) to create/use a block which takes a double pointer as an argument?
For instance:
- (void)methodWithBlock:(void (^)(NSError **error))block;
Additional context, research, and questions:
- I'm using ARC.
- When I declare the method above and attempt to call it, XCode autocompletes my method invocation as follows:
[self methodWithBlock:^(NSError *__autoreleasing *error) {}];
What does__autoreleasing
mean here and why is it being added? I presume it has something to do with ARC. - If this is possible and safe, can the pointer still be dereferenced in the block as it would be anywhere else?
- In general, what are the important differences between doing what I'm describing, and simply passing a double pointer as a method parameter (e.g.
- (void)methodWithDoublePointer:(NSError **)error;
)? What special considerations, if any, should be taken into account (again assuming this is possible at all)?
© Stack Overflow or respective owner