Wednesday, August 19, 2015 [Tweets] [Favorites]

Generic “Functions” in Objective-C

Arkadiusz Holko:

Since the only way to declare generic parameters and return values is through a class interface, we’ll wrap our map method in a new class[…]

[…]

AHKArrayMapper’s only method takes an array of InputType objects and a block mapping from InputType to OutputType. It returns an array of OutputType objects. The implementation doesn’t really differ from the one without generics, because generics aren’t available in implementation files[…]

Objective-C generics are useful for interfacing with Swift and for documenting APIs. I’m not sure that it really makes sense to code with them this way.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment