0

Using MFSideMenu, installed through Pods, but not working and crashing. Below is my code:

let storyBoard = UIStoryboard(name: "Main", bundle: nil) as UIStoryboard

let mfSideMenuContainer = storyBoard.instantiateViewController(withIdentifier: "MFSideMenuContainerViewController") as! MFSideMenuContainerViewController 

 // Crashing on above line.. because mfSideMenuContainer comes nil


    let dashboard = TabViewController()
    let leftSideMenuController = storyBoard.instantiateViewController(withIdentifier: "SideMenuViewController") as! SideMenuViewController
    mfSideMenuContainer.leftMenuViewController = leftSideMenuController
    mfSideMenuContainer.centerViewController = dashboard
    let appDelegate  = UIApplication.shared.delegate as! AppDelegate
    appDelegate.window?.rootViewController = mfSideMenuContainer

Also,

import MFSideMenu

// Error:

  Could not cast value of type 'MFSideMenuContainerViewController' (0x105b67020) to 'MFSideMenuContainerViewController'
iPhone 7
  • 1,731
  • 1
  • 27
  • 63
  • If `let mfSideMenuContainer = storyBoard.instantiateViewController(withIdentifier: "MFSideMenuContainerViewController") as! MFSideMenuContainerViewController ` is causing the crash, it means that `storyBoard.instantiateViewController(withIdentifier: "MFSideMenuContainerViewController")` is either nil OR it's not a `MFSideMenuContainerViewController`, which one is it? – Larme May 27 '21 at 13:22
  • checked that already, it is same. But would like to mention that this storyboard is copied from different project. But that should not make any affect – iPhone 7 May 27 '21 at 13:27
  • What's the output of`print("VC: \(storyBoard.instantiateViewController(withIdentifier: "MFSideMenuContainerViewController")")`. What's the output? It's unclear if you correctly have a VC with that Id, if it's class it correctly set or not. – Larme May 27 '21 at 13:32
  • nil it prints on console, checked with breakpoints – iPhone 7 May 27 '21 at 13:33
  • Check or uncheck inherits target from module? https://stackoverflow.com/questions/55165240/xcode-storyboard-class-has-no-module – Larme May 27 '21 at 13:36
  • Reply to your previous comments: po storyBoard.instantiateViewController(identifier: "sidecontainer") Output: – iPhone 7 May 27 '21 at 13:37
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/232956/discussion-between-iphone-7-and-larme). – iPhone 7 May 27 '21 at 13:42

0 Answers0