Where to put reusable functions in IOS Swift?

The best way is to create a helper class with static functions, like this:

class Helper{
    static func postRequest() -> [String:String] {
         // do a post request and return post data
         return ["someData" : "someData"]
    }
}

Now every time you need to use postRequest you can just use like so: Helper.postRequest()

Leave a Comment

tech