The simplest task would be to allow the lambda to capture the pointer variable of the m_myView object (I assume from your fragment that it is a local variable) and usually use it inside the lambda:
MyLambdaType myLambda = [m_myView]() { // Do something with `m_myView` }
The only concern is m_myView memory m_myView . To be generally correct, a lambda must save m_myView when it is created, and release it when it is destroyed (just like blocks do, because lambda can be used in an area where m_myView does not exist).
Reading through ARC docs, I donβt see this situation specifically mentioned, but I believe that it should handle it properly, because (1) the captured lambda C ++ 11 variables are stored as fields of an anonymous class that are initialized with the captured value when building a lambda, and (2) ARC correctly handles saving and releasing fields of an Objective-C object of C ++ classes when building and destroying. Unless he says something specifically about lambdas to the contrary, or there is a compiler error, I see no reason why this should not work.
newacct
source share