In iOS block how to modify variables outside without using __block -


i read if block wants modify variable outside, variable has described using keyword __block since has copied heap block itself.

but if not want use __block , still modify variable, there way?

i did thinking maybe can set variable global or static instead of auto 1 stored in static memory area.

or can set pointer , point content allocated on heap? tried case didn't work, know why.

essentially, in order avoid losing variable, block copy local variable onto heap if access , modify variable. if make variable global or static, stored on global region , don't need worry losing on stack, block wouldn't copy able modify directly.

please correct me if mistake , mark myself answer if there isn't better one.


Comments