Is it possible to assign a local variable a value whose scope is outside a block and have it retain its value? In particular, I\'m coding for iOS and I have a nested block i
First, str will get updated only after the block is executed. So unless you are using dispatch_sync for that block otherwise at this line:[str getCharAtIndex:1]; the block is unlikely to be executed and str will not get updated.
Second, __block variable will not automatic retained by the block object if you are not using ARC. This means if you are not retain it, than by the time you accessing str, str may be a deallocated object and crash your app.