Skip to content

Instantly share code, notes, and snippets.

@itod
Last active October 6, 2015 20:38

Revisions

  1. itod renamed this gist Feb 13, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. itod revised this gist Jul 5, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // compiled with ARC enabled

    NSArray *foo() {
    NSMutableArray *res = [NSMutableArray array];
    for (int i = 0; i < 3; i++) {
  3. itod created this gist Jul 5, 2012.
    23 changes: 23 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    NSArray *foo() {
    NSMutableArray *res = [NSMutableArray array];
    for (int i = 0; i < 3; i++) {
    [res addObject:^{
    NSLog(@"%d", i);
    }];
    }
    return res;
    }

    int main(int argc, const char * argv[]) {
    @autoreleasepool {
    NSArray *funcs = foo();
    for (void (^func)(void) in funcs) {
    func();
    }
    }
    }

    // prints:
    // 0
    // 1
    // 2