gpt4 book ai didi

objective-c - Cocoa 应用程序 - XCode 8 和 App Delegate

转载 作者:行者123 更新时间:2023-12-03 17:09:38 24 4
gpt4 key购买 nike

在 XCode 7 中,我得到了如下的 ManagedObjectContext:

[[[NSApplication sharedApplication] delegate] managedObjectContext]

在 XCode 8 中,我在 managementObjectContext 上收到错误消息:

Instance method 'managedObjectContext' not found;

如何访问应用程序的 ManagedObjectContext ?

最佳答案

解决方案是:

AppDelegate* appDelegate = (AppDelegate*)[[NSApplication sharedApplication] delegate];

_managedObjectContext = [appDelegate managedObjectContext];

像这样调用应用程序委托(delegate)的问题:

[[NSApplication sharedApplication] delegate]

关于objective-c - Cocoa 应用程序 - XCode 8 和 App Delegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42421761/

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