Executing Blocks From NSArray?

前端 未结 3 1541
囚心锁ツ
囚心锁ツ 2021-01-31 08:35

I was just thinking, as you can treat Blocks like objects if I create two of them and then add them to an NSArray is there a way to execute them from the array?

         


        
3条回答
  •  猫巷女王i
    2021-01-31 09:00

    Of course you can.

    int (^x)(void) = [array objectAtIndex:0];
    printf("%d\n", x()); // prints 101.
    

提交回复
热议问题