You may have heard of functioning programming or higher-order functions, like map
, filter
, reduce
, flatMap
, etc., for Swift. Trust me, if you start to use them in your projects today, you will love them. The approach to use functions as arguments in another function is so handy and succinct that it’s very addictive and hard to reject.
And, what about Objective-C? Are we able to take the same ideas or similar manners in it? Yes, we can. We can create an NSArray
category and iterate each element of it to achieve an identical result. In this article, I’ll demonstrate how to create block based functions for map
, filter
, reduce
and flatMap
in Objective-C.
#swift #xcode #ios #objective-c