m1entus / MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MIT License
973 stars 146 forks source link

MZFormSheetPresentationViewController subclass initializer infinite loop. #161

Closed ryancrunchi closed 6 years ago

ryancrunchi commented 6 years ago

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