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
Post a Comment