Block APIs are NOT harmful
July 17, 2014
Note: This is a repost of an older post that was published on my tumblr blog. Before I begin writing more posts on the subject of programming, I thought I’d practice by reposting something I’ve already written. This post has been re-edited for clarity.
I take exception to Drew Crawford’s recent post that block-based APIs introduce “harmful” surprising side effects into Objective-C, especially under ARC. Drew’s post calls attention to
NSNotificationCenter in particular, but really, any block-based API is susceptible to similar kinds of pitfalls.
I would encourage you to download a copy of Drew’s example code as you read his blog post to understand the problem he’s describing.