The Power of Generics : Swift


One of the most powerful features introduced in Swift was Generics. Generics are used to avoid duplication and to provide abstraction. The generic code allows you to write flexible, reusable functions and data types that can work with any type that matches the defined constraints. Swift standard libraries are built with generics code.¬†Swift’s ‘Array’ and…
Read more

Higher order functions in Swift


Higher-order functions are functions that can accept other function or closure as parameters. I’ll introduce some very useful higher-order functions. Those functions are Map, Filter, Reduce, Sorted, CompactMap, Chaining, Contains. Other new higher-order functions were introduced in Swift 4.2. Those functions are AllSatisfy, FirstIndex, LastIndex and RemoveAll. Map Map function can be used to loop…
Read more

Codable in Swift 4


The Codable protocol was introduced in the release of Swift 4 so, now Swift 4 or later version has built-in support for working with JSON using the Codable protocol. Most commonly The JSON is using to send and receive data from web service. Swift will allow you to convert freely between that data and JSON…
Read more