gpt4 book ai didi

iphone - 将 managedObjectContext 传递给 UITabBarController 的 View

转载 作者:可可西里 更新时间:2023-11-01 05:03:35 25 4
gpt4 key购买 nike

我有一个基于 Utility 模板的应用程序(您可以在其中翻转 View 以查看另一个 View )。在第一个 View 中有一个登录屏幕,然后翻转过来显示一个 UITabBar 风格的界面。

我无法弄清楚如何将 managedObjectContext 从 App Delegate(创建它的地方)一直传递到每​​个选项卡栏的 View 。

App Delegate 的 managedObjectContext 被传递给 FrontLoginViewController,后者被传递给 BackViewTabBarViewController .. 下一步在哪里?

BackViewTabBarViewController nib 有一个 UITabBarController,每个选项卡都有一个 UINavigationController。

最佳答案

听起来 managedObjectContext 是在您的 AppDelegate 中定义的。如果是这样,那么......

从你想要的任何 viewController... 只需调用

MyApplicationDelegate *appDelegate = (MyApplicationDelegate *)[[UIApplication sharedApplication] delegate];

然后使用...

appDelegate.managedObjectContext

每当您需要 managedObjectContext 时。将 MyApplicationDelegate 更改为您的 AppDelegate,您应该可以开始了。

关于iphone - 将 managedObjectContext 传递给 UITabBarController 的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3970952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com