Obj-C: __block variables

后端 未结 3 1503
攒了一身酷
攒了一身酷 2020-12-20 02:06

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

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-20 02:19

    You're just defining that block, but not executing it. call someBlock(valueForParam1); to execute your block. Otherwise your str pointer points to some garbage and calling getCharAtIndex: crashes your app.

提交回复
热议问题