ios - Calling a func from one class in another class - swift -
i have class viewcontroller
. in class, sigviewcontroller
, have function captures image of signature. call function in viewcontroller
class (specifically in ibaction).
in viewcontroller
have following.
@ibaction func sigsave(sender: anyobject) { sigviewcontroller().getsignature() }
in sigviewcontroller
function is...
func getsignature() ->uiimage { uigraphicsbeginimagecontext(cgsizemake(self.bounds.size.width, self.bounds.size.height)) self.layer.renderincontext(uigraphicsgetcurrentcontext()) var signature: uiimage = uigraphicsgetimagefromcurrentimagecontext() uigraphicsendimagecontext() println("saved image") return signature }
the viewcontroller
returning error `use of unresolved identifier sigviewcontroller.
thanks help.
getsignature()
instance function need make instance of sigviewcontroller
class call it. can call class functions in class using syntax classname.functionname()
if mark function class function. when don't have access non class level instance variables.
regular functions - methods in objective-c, class functions + functions.