0

I have a custom class that uses UIView or NSObject etc.. and I override the init, however I want to be able to pass a custom parameter to this class when it initializes, but I can't figure out how to do that. Any ideas?

class SettingLauncher: NSObject, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
    override init(controller: UIViewController){
        // cant pass this as a param, causes error
        super.init()
    }
}

What I want to be able to do is

let settingsLauncher = SettingLauncher(controller: self)

1 Answer 1

2

I think the error you're encountering is due to the use of override which is used only if you are overriding a method that has the same signature

class SettingLauncher: NSObject, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
    init(controller: UIViewController){
       // init super class accordingly  
       // super.init() 
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.