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 ArticleNSArray+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 ArticleFirst-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 ArticleAutomatic 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 ArticleMulle-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 ArticleSwift 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 ArticleVariable 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 ArticleEmpty 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 ArticleSafer 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 ArticleWeak 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@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 ArticleSwift: 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 ArticleJava 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 ArticleBlock-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 ArticleNSArray+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 ArticleNSNotificationCenter 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 ArticleFrom 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 ArticleEffective 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 ArticleAvoid 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 ArticleRXTraversal
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