gpt4 book ai didi

objective-c - Realm swift 创建 objective-c 文件

转载 作者:行者123 更新时间:2023-11-28 13:13:18 26 4
gpt4 key购买 nike

我刚刚开始在我的项目中使用 Realm 。

我有一个 Cocos2D 游戏项目,是用 spritebilder 创建的。代码在 swift 中,除了我不知道为什么的 appdelegate 在 objective-c 中。我刚刚按照说明添加了 https://realm.io/docs/swift/latest/ , Realm 到我的项目。

我希望我的所有设置都是正确的,因为项目设置在最近几个 xcode 版本中发生了一些变化。

但现在当我创建新模型时,它不会快速创建 objective-c(.h 和 .m)文件。

有谁知道为什么和/或如何解决这个问题?

感谢您的帮助

编辑:

我也再次尝试使用 realm objective-c,因为我注意到如果我想为 iOS 7 创建项目,我必须使用这个版本 https://realm.io/docs/objc/latest/但仍然不知道如何为 swift 创建模型。

最佳答案

不要使用 Xcode 新文件中的创建新模型。

创建一个 Swift 文件并自己编写 Realm 对象。

这是 Realm 对象在 Swift 中的样子:

import RealmSwift

// Dog model
class Dog: Object {
dynamic var name = ""
dynamic var owner: Person? // Can be optional
}

更多信息请参见 documentation .它向您展示了如何在安装步骤之后一开始就创建模型。

关于objective-c - Realm swift 创建 objective-c 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30396135/

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