mercredi 22 avril 2015

Calling a func from one class in another class - swift

I have a class viewcontroller. In another class, SigViewController, I have a function which captures an image of a signature. I would like to call the function in the viewcontroller class (specifically in an IBAction).

In viewcontroller I have the following.

@IBAction func sigsave(sender: AnyObject) {
    SigViewController().getSignature()
}

In SigViewController the 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 is returning the error `Use of unresolved identifier SigViewController.

Thanks for any help.

Aucun commentaire:

Enregistrer un commentaire