gpt4 book ai didi

ios - 找不到类,改用默认的 NSManagedObject

转载 作者:技术小花猫 更新时间:2023-10-29 10:18:26 26 4
gpt4 key购买 nike

我在 IOS 8 中遇到核心数据问题。每当我想使用 insertNewObjectForEntityForName 方法时,我都会得到

Class not found, using default NSManagedObject instead.

错误信息。我使用 objective-c,使用 IOS 7 时没有这个问题。也可能有任何问题,因为在我的工作区中有两个项目,一个包含核心数据相关代码,另一个包含 UI。

最佳答案

当使用 Swift 时,如果源文件包含在 Build Phases > Compile Sources 中,错误仍然可能出现

unable to load class named '...' for entity '...'. class not found, using default nsmanagedobject instead.

要解决此问题,您可以在模型检查器中为特定模型类添加前缀(此处使用 MyApp)。 See also the documentation .

enter image description here

我们可以在快速类声明之前添加 objc(Person)

@objc(Person)
class Person: NSManagedObject {
...
}

关于ios - 找不到类,改用默认的 NSManagedObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25869231/

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