Quantcast
Channel: Blocks – Michael Tsai
Browsing latest articles
Browse All 29 View Live

CTBlockDescription

Oliver Letterer’s CTBlockDescription is a class for introspecting block Objective-C blocks (via Ole Begemann).

View Article



Objective-C Blocks Quiz

Bryan Klimt: Do you really know how blocks work in Objective-C? Take this quiz to find out. Educational, although I think it confuses what works in the current implementation with what is contractually...

View Article

Block Debugging

Damien DeVille: We are mostly interested about the first method argument (the third argument of the objc_msgSend function) which happens to be a stack block. Now, obviously we know exactly what the...

View Article

RXCollections

Rob Rix’s RXCollections offers: Folds, maps, filters, and detects for Cocoa collections (including your own), with as little chaff as possible. The interesting part is that: Maps and filters take a...

View Article

ReactiveCocoa Explanation

Josh Abernathy: Because we treat all the inputs to our app as different things—a touch event here, a web response there—we can’t combine them in any meaningful way. We can’t transform them uniformly....

View Article


NSEnumeratorLinq

Ash Furrow: Anton Bukov has done a great job replicating the LINQ framework in the Foundation collections classes.For those of you who aren’t former .Net fanboys, LINQ is the gem of .Net development....

View Article

Leak-Free Recursive Blocks

Jeremy W. Sherman (via Romain Briche): So you need both a strong and a weak reference to your block. And the block needs to be stored in the strong reference first, so you anchor it to this world. And...

View Article

Presenting BlockAssert

Steven Fisher: For various reasons, you sometimes can’t use NSAssert in a block easily. I’m going to explain why and describe a new macro, BlockAssert, which solves this.

View Article


Lazy Evaluation and Streaming With NSFastEnumeration

Rob Rix: Since Wolf and Michael’s posts, the old RXMap that took a second argument as the collection to fold the mapped results into is gone. In its place is an RXMap which returns an object conforming...

View Article


RXTraversal

Rob Rix: Perhaps more damningly, it’s particularly difficult to compose NSFastEnumeration, e.g. to produce objects based on the enumeration of some other object, as with a map, or worse, a convolution...

View Article

Avoid Null Checks by Replacing Finders With Tellers

Michael Feathers:The person method accepts an id for a person and a block. If the person is found the block is called with the person. Otherwise it isn’t. Elegant, eh? And, there are no nulls.Lots of...

View Article

Effective Objective C 2.0

Mark Bernstein on Matt Galloway’s Effective Objective C 2.0: This book is organized and presented as an Objective C homage to Scott Meyers’ classic work, Effective C++. The new book is good and...

View Article

From C Declarators to Objective-C Blocks Syntax

Nils Hayat: In this post, I start with the simplest C declarator and build in complexity until we get to Objective-C blocks syntax. It took me a while to get block syntax but once you understand how it...

View Article


NSNotificationCenter With Blocks Considered Harmful

Great post from Drew Crawford: This could be, I think, the single biggest API blunder in iOS. (Except maybe iCloud Core Data.) I have debugged issues that were root-caused to this misleading API more...

View Article

Java 8

Andrew Binstock: What makes Java 8 so compelling is its embrace of the functional programming metaphor. This embrace has two primary expressions: the use of closures (or as Java calls them, “lambdas”)...

View Article


Swift: Objective-C Without the Smalltalk

David Owens II has some criticisms along this line that differ from those I mentioned before (via Christoffer Lernö): Gone is the dynamic nature of ObjC; it has instead been replaced by a rigid,...

View Article

@weakify and @strongify Macros

Arkadiusz Holko: Original implementation of @weakify and @strongify macros is complex because they accept more than one parameter. To make the analysis simpler, we’ll introduce our own versions,...

View Article


Weak and Unowned References in Swift

Hector Matos: At this point we have a retain cycle. You see, closures in Swift behave exactly like blocks in Objective-C. If any variable is declared outside of the closure’s scope, referencing that...

View Article

Safer Block-based NSNotificationCenter API

Arkadiusz Holko: I wanted to learn how Clang decides when to show a warning, so I did what any reasonable person would do and dove into its source. Retain cycle checking is performed during the...

View Article

Empty Parentheses Are Not “No Parameters” in (Objective-)C

Jonathan Mah: Using () in a function type declaration means unspecified parameters. This is a very old feature of C that has been maintained for backward compatibility. In fact, it was noted as an...

View Article

Variable Capture and Loops

Tim Ekl: The difference, it turns out, has to do with how variables are bound in loops, and how values are captured in anonymous functions. The Swift (and Objective-C) behavior – which I was most used...

View Article


Swift Closure Capture Semantics

Olivier Halligon: One important thing to note though is that in Swift the captured variables are evaluated at the closure execution’s time1. We could say that it captures the reference (or pointer) to...

View Article


Mulle-objc: a New Objective-C Compiler and Runtime

mulle-objc (Hacker News): mulle-objc is a new way to run Objective-C code on various platforms, based on a new compiler and a new runtime.mulle-objc goalsRun everywhere C runsEverything faster than...

View Article

Automatic Memory Leak Detection on iOS

Facebook: Automating this process would allow us to find memory leaks faster without much developer involvement. To address that issue, we have built a suite of tools that allow us to automate the...

View Article

First-Class Swift API for Objective-C Frameworks

Marcin Krzyżanowski: In Objective-C, it’s possible to store a block as an id type, e.g. in a collection like NSDictionary<String *, id>. However, that’s a trap. If we store a Swift closure in the...

View Article


NSArray+Functional

Nicolas Seriot has written a category on NSArray to add map, filter, and reduce functionality. You pass a selector and a variable number of arguments, and it performs the selector on each object in the...

View Article

Block-Based Dictionary Enumeration Can Be Pretty Slow

You’d expect that -[NSDictionary enumerateKeysAndObjectsUsingBlock:] would be faster than fast-enumerating the keys and then looking up the objects, as it could access both at the same time while...

View Article
Browsing latest articles
Browse All 29 View Live




Latest Images