AuthorShashikant Bhadke

Decodable in Swift 4

D

According to Apple Codable is “A type that can convert itself into and out of an external representation.” Encodable — for encoding Decodable — for decoding Codable — for both encoding as well as decoding Let suppose we need to decode json response of type as below, [ {               "name": "India",               "dial_code": "+91",               "code": "IN"             } ] For...

Higher Order Function in Swift PART 2

H

Let’s start with FlatMap where few point need to cover. So lets begin, Flatmap Flatmap is used to flatten a collection of collections. let temp_Dictionary = [["k1":"v1","k2":"v2"],["k3":"v3","k4":"v4"]] let flatMap_1 = temp_Dictionary.flatMap { $0 } //[(key: "k2", value: "v2"), (key: "k1", value: "v1"), (key: "k3", value: "v3"), (key: "k4", value: "v4")] It returns an array of tuples after...

Higher order functions in swift

H

As far as I understood, higher order functions are functions that takes another function/closure as argument and/or returns it. Higher order functions are simply functions that operate on other functions by either taking a function as an argument, or returning a function. Swift’s Array type has a few methods that are higher order functions: sorted, map, filter, and reduce. These methods use...

Animation like floating Buttons.

A

Hi all, today we will check out simple but cool floating buttons using UIViewAnimations methods. So, in this we are going to show 4 buttons which came out upside from another button. Here we are using constraints of  buttons, button and UIViewAnimations. Let’s start with  adding constraint to each buttons. 1) Setting constraints for buttons:-     Add constraint such that bottom constraint...

Category