vtourraine / AcknowList

Acknowledgements screen displaying a list of licenses, for example from CocoaPods and Swift Package Manager dependencies.
MIT License
807 stars 60 forks source link

Subclass? #3

Closed bryanbartow closed 8 years ago

bryanbartow commented 8 years ago

I've been trying to subclass AcknowListViewController so I can customize the textLabel appearance in the cellForRowAtIndexPath method. Unfortunately, I can't seem to get past the must call designated initializer method error. I've tried calling / overriding every combination of init method I can think of. Is there any way to subclass this? I can't think of any other way to get to the table view cell.

bryanbartow commented 8 years ago

@vtourraine?

vtourraine commented 8 years ago

I’m not very familiar with Swift (yet), so I don’t really know how to solve this situation.

If you just need to customize the cells, you shouldn’t need to touch the controller initializers. When does this error occur exactly (compile, run time, where)?

bryanbartow commented 8 years ago

@vtourraine The error is at compile time. I'd rather not touch the initializers, but Swift requires the subclass to implement them.

vtourraine commented 8 years ago

Alright. Have you tried with the initializers from AcknowListViewController? It already has to override a couple of initializers from its superclass.

bryanbartow commented 8 years ago

@vtourraine Yes, I've tried with and without those initializers.

vtourraine commented 8 years ago

Got this to compile:

class CustomAcknowListViewController: AcknowListViewController {
    required convenience init(coder aDecoder: NSCoder) {
        self.init(acknowledgementsPlistPath: nil)
    }
}

The current initializers configuration might be problematic for people using Storybards/XIBs. Room for improvements, as always.

bryanbartow commented 8 years ago

@vtourraine That worked! I could swear I tried it already, but oh well. Thanks. I'll leave it up to you whether you want to close this ticket or not.

vtourraine commented 8 years ago

Great, happy to hear that.

I’ll close this issue, but it got me thinking about the initializers configuration (designated/convenience/etc), and I might change all that for a future version. If someone more comfortable with Swift than me can figure out a better solution, pull-requests are welcome.