Using blocks to handle errors

In the past, I’ve talked about Using blocks to remove redundancy. But now I want to explain the pattern I’ve adopted since, which is my favorite block pattern of all. Even though it, too, is all about removing redundancy: handling errors. Although Objective-C supports exceptions, they’re not commonly used. A thrown exception is usually not… Continue reading Using blocks to handle errors

Blocks to remove redundancy

Blocks have many complicated uses, from event-based code to multithreading. But they can also be used for very trivial tasks, such as removing redundant lines from code. Here’s a common operation for me: Split a list into sublists based on some piece of data changing within a loop. When the loop is over, dump whatever’s… Continue reading Blocks to remove redundancy