1

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

Black Frog
  • 11,595
  • 1
  • 35
  • 66
Daniel Storch
  • 979
  • 3
  • 10
  • 25
  • I'm guessing it's because `imageCropVC` is already an initialized object. Looking at the header file, I think you may try using `let imageCropVC = RSKImageCropViewController(initWithImage: ...)` instead? Just a thought. – Eric Aya Apr 17 '15 at 14:10
  • i got it to work. Your answer was kind of correct. this is how it looks now `let imageCropVC = RSKImageCropViewController(image: image)` – Daniel Storch Apr 17 '15 at 16:10
  • Cool! I'm going to transform my comment into a proper answer so it can help other users. – Eric Aya Apr 17 '15 at 16:11

1 Answers1

4

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)
Eric Aya
  • 69,473
  • 35
  • 181
  • 253