Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: A Y Combinator for Objective-C (github.com/jballanc)
97 points by jballanc on April 13, 2011 | hide | past | favorite | 4 comments


That's cool, but it's actually possible to use recursive blocks directly if you simply declare the block as a __block variable. This works perfectly fine:

  __block void (^myBlock);
  myBlock = ^{ myBlock(); };
  myBlock();
The only thing you have to watch out for is when the block gets copied prior to its invocation (e.g. if you pass it to some function that does a Block_copy on it). In that case you have to first copy the block yourself and update your block variable:

  __block void (^myBlock);
  myBlock = [^{ myBlock(); } copy];
  someFunctionThatCopiesTheBlock(myBlock);


Heh, I was wondering when someone would bring this up. For most cases, this also works. I will say that I've seen cases where this technique hasn't worked, but those were all far, far more complex than most any Obj-C programmer will ever need to worry about.


This has to be the most unboring README file I ever read. The fun.m and nofun.m have a nice touch too.


I really appreciate the overview that author gave in readme. Quite often links to seemingly interesting github projects are submitted, but I am unable to figure out the 'really cool' parts. Explanation adds much value to playing with the project.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: