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.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -