The Shape of Everything
A website mostly about Mac stuff, written by Gus Mueller
» Acorn
» Twitter
» Maybe Pizza?
» Code
» Archive
February 3, 2012

Every once in a while I see someone ask (twitter, irc, etc.) if it is possible to recursively call a block. Yes, it is- and it's very useful in your own code as well. Here's a simple example:

__block void (^rBlock)(int i) = ^(int i) {

    if (i > 10) {
        return;
    }

    printf("%d\n", i);

    rBlock(i+1);
};

rBlock(0);