无法在SceneDelegate中传递NSPersistentContainer

时间:2019-12-03 11:19:03

标签: swift core-data

我正试图将NSPersistentContainer的{​​{1}}传递给SceneDelegate,但我不断收到此错误:

  

“致命错误:FocusTabBarController需要一个容器”

不确定我在做什么错。请帮忙吗?

UITabBarController

SceneDelegate

let containerObject = (UIApplication.shared.delegate as! AppDelegate).persistentContainer let tabBarController = FocusTabBarController() tabBarController.container = containerObject // Use a UIHostingController as window root view controller. if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) window.rootViewController = tabBarController self.window = window window.makeKeyAndVisible() }

FocusTabBarController

0 个答案:

没有答案