swiftmenuappdelegatexcode11swrevealviewcontroller

Problem with SWRevealViewController For Xcode 11


I have all my code set up for SWRevealViewController it worked perfectly fine on Xcode 10.3 and even on Xcode 11.2 beta 2 but for some reason its not working on the recent update release from the App Store and I end up getting this error, at the app delegate

Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)

screen after I toggle with my SWRevealView Controller. any ideas how I could get this fixed

Just weird to me since I've never had a problem with the SWRevealViewController before

here's the code that I use on my ViewDidLoad for all my view controllers and the code for my App Delegate

    menuButton.target = self.revealViewController()
    menuButton.action = #selector(SWRevealViewController.revealToggle(_:))

    self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

import UIKit
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Onboarding
        let launchedBefore = UserDefaults.standard.bool(forKey: "hasLaunched")
        self.window = UIWindow(frame: UIScreen.main.bounds)
        let launchStoryboard = UIStoryboard(name:"Onboarding", bundle: nil)
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
        var vc: UIViewController

        if launchedBefore {
            vc = mainStoryboard.instantiateInitialViewController()!
        } else {
            vc = launchStoryboard.instantiateViewController(withIdentifier: "AgeVC")
        }
        UserDefaults.standard.set(true, forKey: "hasLaunched")
        self.window?.rootViewController = vc
        self.window?.makeKeyAndVisible()
        // Onboarding End

        FirebaseApp.configure()

        // Override point for customization after application launch.
        UITabBar.appearance().barTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        UITabBar.appearance().tintColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        UITabBar.appearance().unselectedItemTintColor = #colorLiteral(red: 0.2, green: 0.9333333333, blue: 0.4588235294, alpha: 1)

        UINavigationBar.appearance().barTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        UINavigationBar.appearance().tintColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]

        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

Slide Menu

import UIKit

let kStringTransfer = "StringTransferNotification"

class MenuViewController: UITableViewController {

    @IBOutlet weak var addressLabel: UILabel!
    @IBOutlet weak var addressBtn: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()

        NotificationCenter.default.addObserver(self, selector: #selector(setString(notify:)), name: NSNotification.Name(rawValue: kStringTransfer), object: nil)

        self.revealViewController().rearViewRevealWidth = self.view.frame.width-100//put the width you need
        self.revealViewController().rearViewRevealOverdraw = 0
    }

    @objc func setString(notify: Notification) {
        //set search bar string to text field
        addressLabel.text = notify.object as? String
    }

    func userDidEnterInformation(info: String) {
        addressLabel.text = info
    }
}

side not it does work a few times before it crashes


Solution

  • Found the answer, IT was just missing a SceneDelegate Class in the code for it to work, now it works smoothly