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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -