realm

Realm: Results<T> als List<T>

走远了吗. 提交于 2019-11-30 17:50:41
Is it possible to convert Results<T> to List<T> or shouldn't I do this? In my case I have method that has List as a parameter. I want to call this method with fetched objects ( Results<T> ) and with computed objects ( List<T> ) Results and List implement CollectionType and RealmCollectionType . The latter is a specialization of the former protocol, which allows you to efficiently use aggregation functions and filter & sort entries. Almost no method in Realm Swift make strong assumptions about the type of the collection. They just expect a SequenceType which is a generalization of the former

Instantiating Realm database for Swift 2.0 - best practice?

风流意气都作罢 提交于 2019-11-30 17:47:05
I'm wondering what the best practice for instantiating a Realm database is for Swift 2. One of the major differences between Realm for Swift 1.2 and Swift 2 is that the Realm class has added support for error handling. Therefore, this code on the Realm website does not work anymore: let realm = Realm() I can think of a couple ways to instantiate a Realm class in the Swift 2 world: (1) let realm = try! Realm() This option seems a little "unsafe" to me as it potentially results in a runtime error if the class fails to instantiate. (2) Place entire Realm operation (including class instantiation)

Realm - Can't create object with existing primary key value

两盒软妹~` 提交于 2019-11-30 17:45:21
I have a object Person with many dogs. App has separate page where it shows just dogs and other page where it shows person's dogs My model is as follows class Person: Object { dynamic var id = 0 let dogs= List<Dog>() override static func primaryKey() -> String? { return "id" } } class Dog: Object { dynamic var id = 0 dynamic var name = "" override static func primaryKey() -> String? { return "id" } } I have persons stored in Realm. Person has detail page where we fetch and show his dogs. If dog already exist, I update latest info for that dog and add it to person's dog list else create new dog

Custom methods in RealmObjects… solution?

我只是一个虾纸丫 提交于 2019-11-30 17:25:17
问题 I am using Realm as a data module in my android application, though I am running into some problems regarding how to assign custom methods to Realm objects. In the iOS coredata module, you have NSObjects which save to memory and also permit malleability within their respective classes. What sort of system can I use to get around this? I tried making "Parent Classes" for all of my realm objects, but this didn't work. For example: "TeacherRealm" would only contain the getters and setters for a

STUN/TURN服务器搭建

孤街浪徒 提交于 2019-11-30 17:00:00
目录 STUN/TURN服务器搭建 编译安装 配置使用 添加用户 启动server 测试 开机启动 参考 STUN/TURN服务器搭建 编译安装 编译安装 OpenSSL; sudo apt-get install libssl-dev 编译安装 libevent 最新版; wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz tar xvfz libevent-2.0.21-stable.tar.gz cd libevent-2.0.21-stable ./configure make sudo make install coturn 可以选择使用多种数据库,这里使用的是 SQLite ,使用命令 sudo apt-get install sqlite (or sqlite3) 和 sudo apt-get install libsqlite3-dev (or sqlite3-dev) 安装; 编译coturn; 下载 coturn tar xvfz turnserver-<...>.tar.gz ./configure make sudo make install 执行 ./configure 命令时没有使用 --prefix=/opt 参数,因为 OpenSSL

This Realm instance has already been closed, making it unusable + RxJava

。_饼干妹妹 提交于 2019-11-30 16:00:07
First of all i manage realm instance by Repository class: public class RealmRepository { private Lock lock; protected RealmRepository() { lock = new ReentrantLock(); } public <T> T execute(Executor<T> executor) { Realm realm = null; try { lock.lock(); realm = Realm.getDefaultInstance(); return executor.execute(realm); } finally { if (realm != null && !realm.isClosed()) { realm.close(); } lock.unlock(); } } public interface Executor<T> { T execute(Realm realm); } } And the only class that extends by this RealmRepository, this is my controller class. Problem is when i do at first time execute

realm mobile platform, how to connect while offline?

折月煮酒 提交于 2019-11-30 15:40:59
the new realm mobile platform is advertised with offline support, however most tutorials does not show how that works in the examples... for example, in their todo app example this is the code used to connect to the server database SyncUser.logIn(with: .usernamePassword(username: username, password: password, register: false), server: URL(string: "http://127.0.0.1:9080")!) { user, error in guard let user = user else { fatalError(String(describing: error)) } DispatchQueue.main.async { // Open Realm let configuration = Realm.Configuration( syncConfiguration: SyncConfiguration(user: user,

Realm ORM: how to deal with Maps?

会有一股神秘感。 提交于 2019-11-30 15:17:05
问题 I am creating an Android app and I need to persist a Map<String,MyClass> . I've just started to use Realm ORM, as it supports one-to-one and one-to-many, enumerations and lists. I also found a workaround for lists of strings (i.e. I have to create a StringWrapper class encapsulating a string. However, from the documentation I understand there is no easy way like RealmMap , as it happens for lists. So, I'm looking for the best way to persist a map. My current idea is to replace my map with a

Realm ORM: how to deal with Maps?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 13:30:50
I am creating an Android app and I need to persist a Map<String,MyClass> . I've just started to use Realm ORM , as it supports one-to-one and one-to-many, enumerations and lists. I also found a workaround for lists of strings (i.e. I have to create a StringWrapper class encapsulating a string. However, from the documentation I understand there is no easy way like RealmMap , as it happens for lists. So, I'm looking for the best way to persist a map. My current idea is to replace my map with a list of objects KeyValueObject encapsulating a String (the former map key) and a MyClass . Similarly to

Is there a realm browser for Linux?

為{幸葍}努か 提交于 2019-11-30 13:27:52
问题 I would like to browse a realm database using a browser. I'm a Linux user and I know the realm browser is only for MacOS. I also have knowledge about Stetho by Facebook and I read about this project https://github.com/uPhyca/stetho-realm too. However I don't want to add unnecessary libraries in my project and I install Google Chrome to browse a database, this is odd for me. So, do you know if there's a realm browser for Linux? Thanks in advance. 回答1: I am happy to say that my previous answer