Hacker News new | past | comments | ask | show | jobs | submit login
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 W25 batch! Applications are open till Nov 12.

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

Search: