Search code examples
objective-cswiftios-library

Using RSKImageCropper library in Swift Project


Im trying to use RSKImageCropper in my Swift project but dont know how. I have an Bridging-header file with this line of code

#import "RSKImageCropViewController.h"

In my Controller i can create an instance of RSKImageCropViewController like this

let imageCropVC = RSKImageCropViewController()

but after that, i cant get it to work. When calling imageCropVC.initWithImage() i get an error. Im trying to convert the example Objectiv-C methode on the github page to Swift.

What am i doing wrong? Is it even possible to use this library in my Swift project? It would be nice if someone could post the right code in Swift.

Thanks


Solution

  • With

    let imageCropVC = RSKImageCropViewController()
    

    you're initializing a controller with the init method.

    So you can't use the initWithImage() method on this imageCropVC instance, because it would mean to initialize it again.

    What you want is to initialize a new controller with an image:

    let imageCropVC = RSKImageCropViewController(image: yourImage)