我一直在关注Realm的this教程,但遇到了麻烦。
因此它说要生成一个Realm模型,为此我们必须通过Alcaraz在Xcode中安装一个插件。真好
现在,我面临的问题是在Xcode 8+中它不允许安装任何外部插件(据我所知,只有那些可以编辑文本的插件)。
我的问题是,既然Xcode 8+不支持外部插件,如何像本教程中所述那样生成领域模型。同样,如果现在不可能,那么我应该如何处理/解决这种数据模型映射。
我在Realms git页面或他们的网站中什么也没有找到解决方案。
任何帮助表示赞赏。
我正在使用Xcode 8.3.2,并且正在使用Swift 3.1
编辑
我已经通过cocoapods安装了Realm。我问是否有像Xcode插件之前一样的Realm Data模型的可视数据生成器,如Core Data xcdatamodel。
最佳答案
You can use CocoaPods
add following to pods file and install -pod install
pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
then , Create model class as following
import Foundation
import UIKit
import RealmSwift
import Realm
class ClassName: Object{
required init(value: Any, schema: RLMSchema) {
super.init(value : value,schema:schema)
//fatalError("init(value:schema:) has not been implemented")
}
required init() {
super.init()
//fatalError("init() has not been implemented")
}
required init(realm: RLMRealm, schema: RLMObjectSchema) {
super.init(realm:realm , schema:schema)
//fatalError("init(realm:schema:) has not been implemented")
}
}
关于ios - Realm 生成模型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44198781/