0

if you're using Swift + CocoaPods + use_frameworks! with the MMDrawerController opened source (ObjC) library you might have trouble subclassing MMDrawerController getting multiple warnings of "unused initializer"

All you'll have to do is override the initializers and call super. Pretty easy but I saw that there was absolutely nothing on this issue while Googling for this issue, so I'm just trying to help out. I've posted my code below.

RyanPliske
  • 391
  • 3
  • 7
  • This should serve as a helper for people Googling for "MMDrawerController+Subclass+Swift" with the question concerning the debugger error of "unused initializers" – RyanPliske Dec 15 '15 at 16:01

1 Answers1

1
import UIKit
import MMDrawerController

class TRDrawerController: MMDrawerController {

    private var recordsModel = TRRecordsModel.sharedInstanceOfRecordsModel
    private var itemsModel = TRItemsModel.sharedInstanceOfItemsModel

    init() {
        let centerViewController = UIStoryboard(name: "TRMain", bundle: nil).instantiateViewControllerWithIdentifier("TRTrackerViewController") as! TRTrackerViewController
        centerViewController.recordsModel = recordsModel
        centerViewController.itemsModel = itemsModel
        let firstNavigationController = TRNavigationController(rootViewController: centerViewController)

        let rightViewController = UIStoryboard(name: "TRMain", bundle: nil).instantiateViewControllerWithIdentifier("TRSettingsViewController") as! TRSettingsViewController
        rightViewController.recordsModel = recordsModel
        centerViewController.itemsModel = itemsModel
        let secondNavigationController = TRNavigationController(rootViewController: rightViewController)

        super.init(centerViewController: firstNavigationController, leftDrawerViewController: nil, rightDrawerViewController: secondNavigationController)
        self.openDrawerGestureModeMask = [.PanningCenterView]
        self.closeDrawerGestureModeMask = [.PanningCenterView, .TapCenterView, .TapNavigationBar]
        self.shouldStretchDrawer = false
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    // Won't be utilizing this, I want the app to crash if this gets used
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
RyanPliske
  • 391
  • 3
  • 7