m1entus/MZFormSheetPresentationController

MZFormSheetPresentationViewController subclass initializer infinite loop.

Closed this issue · 0 comments

When subclassing MZFormSheetPresentationViewController with a custom init it makes an infinite loop. Example (swift) :

class MyPresentationViewController: MZFormSheetPresentationViewController {
    init() {
        let vc = MyViewController()
        super.init(contentViewController: vc)
    }
}

This is due to MZFormSheetPresentationViewController initializer :

- (instancetype)initWithContentViewController:(UIViewController *)viewController {
    if (self = [self init]) {
        ...

which calls [self init] where self is the subclass, which itself is calling initWithContentViewController.

I'm preparing a PR to fix it : just replacing [self init] by [super init].
Edit : #162