Where to put reusable functions in IOS Swift? -


new ios programming wondering best place put functions use throughout code. example, want write few functions perform post request web service , return dictionary. maybe function calculations. best create .swift file , put functions there. , name give file if so?

public func postrequest() -> [string:string] {      // post request , return post data      return ["somedata" : "somedata"] } 

the best way create helper class static functions, this:

class helper{     static func postrequest() -> [string:string] {          // post request , return post data          return ["somedata" : "somedata"]     } } 

now every time need use postrequest can use so: helper.postrequest()

i hope helps you!


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -