ios - callback on function from other class -


i have customview , and there uitextfield, , in viewcontroller, using lot of views. in customview.swift have uitextfielddelegate. want actions on callback in viewcontroller. example : when tap on textfield, delegate executes

func textfielddidbeginediting(textfield: uitextfield) {     println("delegate") } 

and after want function works viewcontroller ui execute, example:

func textfielddidbeginediting(textfield: uitextfield) {         println("delegate")         viewcontroller().check() } 

but gets nil, want create callback, can advise right way this?

create custom property of type viewcontroller in customview class. in viewdidload function of viewcontroller, call

thecustomview.viewcontroller = self 

(where thecustomview instance - have reference well, otherwise create iboutlet)

then, in textfielddidbeginediting function can use

self.viewcontroller.check() 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -