本文介绍了Realm Swift仅在本地使用,但仍尝试在线连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循领域快速入门指南,它运行正常.我有以下对象:

I am following the realm swift getting started guide here and it is working fine. I have the following object:

class Dog: Object {
  dynamic var name = ""
  dynamic var age = 0
}

在我的视图控制器中

override func viewDidLoad() {
    super.viewDidLoad()

    print(Realm.Configuration.defaultConfiguration.fileURL!)

    let myDog = Dog()
    myDog.name = "Rex"
    myDog.age = 1

    let realm = try! Realm()

    try! realm.write {
      realm.add(myDog)
    }
}

小告密报告域已尝试连接到static.realm.ioapi.mixpanel.com.如果只想在本地使用领域,如何阻止领域尝试连接到各种服务器?

little snitch reports that realm tries to connect to static.realm.io and api.mixpanel.com. How do I stop realm from attempting to connect to various servers if I only want to use it locally?

推荐答案

这是预期的行为.

请参阅我们的文档以获取更多详细信息.

Please see our doc for more details.

https://realm.io/docs/swift/latest/#i-see-a-network-call-to-mixpanel-when-i-run-my-app-what -是-那个

在发行版本中不会发生.为了即使在调试版本中也要防止这种情况,请设置名为REALM_DISABLE_ANALYTICS的环境变量.

It doesn't happen in a release build. To prevent this even in debug build, set environment variable named REALM_DISABLE_ANALYTICS.

另请参见 https://github .com/realm/realm-cocoa/blob/master/Realm/RLMAnalytics.mm#L37-L44

这篇关于Realm Swift仅在本地使用,但仍尝试在线连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 11:17