achi achi - 1 year ago 114
Swift Question

Swift 3 init - unexpected error

In what I thought was to be a simple subclass, I can't quite seem to figure out the issue.

Does this error message make any sense?

'super.init' cannot be called outside of an initializer

enter image description here


enter image description here

SKPhoto is declared open, and here are the available inits of the superclass:

// MARK: - SKPhoto
open class SKPhoto: NSObject, SKPhotoProtocol {

open var underlyingImage: UIImage!
open var photoURL: String!
open var contentMode: UIViewContentMode = .scaleAspectFill
open var shouldCachePhotoURLImage: Bool = false
open var caption: String!
open var index: Int = 0

override init() {

convenience init(image: UIImage) {
underlyingImage = image

convenience init(url: String) {
photoURL = url

convenience init(url: String, holder: UIImage?) {
photoURL = url
underlyingImage = holder

I embarassingly can't solve this problem!

Answer Source

There seems to be a problem in the SKPhoto class; it has not made its init methods open so you can not override them in your sub class;

If you really want to use it, you should fork the repo and make appropriate changes, then may use it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download