简体   繁体   中英

Declare Block with return value but no args?

There is no practical reason for this, its just something I was looking at today. Does anyone know if there is a way to create a Block that does not take any arguments. In the example below Block_001 would return 101, does anyone know what I am missing?

int (^Block_001) = ^{ return 101; };

If I add a int argument then the block compiles just fine

int(^Block_001)(int) = ^(int arg){ return 101; };

Gary

你需要void

int (^Block_001)(void) = ^{ return 101; };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM