领域= RLMRealm'没有成员'setDefaultRealmPath' [英] Realm = RLMRealm' has no member 'setDefaultRealmPath'

查看:165
本文介绍了领域= RLMRealm'没有成员'setDefaultRealmPath'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Realm.framework和RealSwift.framework添加到项目中.和导入领域",尽管出现此错误:

I have added the Realm.framework and RealSwift.framework to a project. and "import Realm" though I'm getting this error:

RLMRealm'没有成员'setDefaultRealmPath'

RLMRealm' has no member 'setDefaultRealmPath'

 let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.it.fancypixel.Done")!
        let realmPath = (directory.path! as NSString).stringByAppendingPathComponent("db.realm")
        RLMRealm.setDefaultRealmPath(realmPath)

任何想法我都看不到解决方案,因为它太新了.

Any ideas I can't seem to see a solution for this anywhere being it's so new.

谢谢.

推荐答案

领域(Swift和Objective-C库均已更新)为0.97版.虽然setDefaultRealmPath在过去是有效的API,但随后不推荐使用,并且从0.97开始完全删除了它.这样一来,如果过去可以使用,那么一旦您将其更新为0.97,现在将导致生成错误.

Realm (Both the Swift and Objective-C libraries) was just updated to version 0.97. While setDefaultRealmPath was a valid API in the past, it was subsequently deprecated, and as of 0.97, completely removed. As such, if it was working in the past, once you've updated to 0.97, it will now result in a build error.

现在通过Realm RLMRealmConfiguration对象控制设置Realm的文件位置.要设置默认路径,您现在可以这样:

Setting the file location of a Realm is now controlled via Realm RLMRealmConfiguration objects. To set the default path, you would now do it like this:

let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.it.fancypixel.Done")!
let realmPath = (directory.path! as NSString).stringByAppendingPathComponent("db.realm")

var config = RLMRealmConfiguration.defaultConfiguration()
config.path = realmPath
RLMRealmConfiguration.setDefaultConfiguration(config)

让我知道是否需要更多说明!

Let me know if you need any more clarification!

这篇关于领域= RLMRealm'没有成员'setDefaultRealmPath'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆