What is method chaining ?
In this article I will explain what is method chaining, where we can use and what are the advantages of using. Method chaining is a very less discussed and used topic. Almofire iOS framework mostly uses the method chaining concept. The concept of method chaining is each method initialize some class properties or do something and returns self so that you can call another method on this. Making functions chainable is quite easy and can allow us to write using an almost DSL-like syntax. Let’s consider the below method. func makeRequest(requestURL: String?, method: String?, parameters: [String: String ]?, completionHandler: @escaping ( [String:AnyObject] , bool) -> Void) In the above func if some parameter is not required we have to pass nil for that. Now Let’s consider the below APIRequest class. class APIRequest { var url:URL? var method = HTTPMethods.get var params:[String:String]? enum HTTPMethods: String { // http methods