ios - declaring a global function across all views -


i have function eg. have across views in app. how go defining that. should function written.

read somewhere here 1 possible solution define function uiviewcontroller extension so:

extension uiviewcontroller {     func displayalert(title:string, error:string, buttontext: string) {     ...    } } 

where should such procedure declared?

thanks

create new swift file , name like: uiviewcontroller+displayalert.swift

in there can add code in question.

extension uiviewcontroller {     func displayalert(title:string, error:string, buttontext: string) {     ...    } } 

since extending uiviewcontroller, you'll able access function on subclasses of uiviewcontroller.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -