realm

Unexpectedly large Realm file size

ぃ、小莉子 提交于 2019-12-18 06:23:15
问题 This question is about using two different ways to insert objects into a Realm. I noticed that the first method is a lot faster, but the size result is huge comparing with the second method. The diference between the two approaches is moving the write transaction outside vs inside of the for loop. // Create realm file let realm = try! Realm(fileURL: banco_url!) When I add objects like this, the Realm file grows to 75.5MB: try! realm.write { for i in 1...40000 { let new_realm_obj = realm_obj

How to use List type with Codable? (RealmSwift)

血红的双手。 提交于 2019-12-18 04:16:45
问题 Problem is List type does not conform to Codable, the below class cannot be insert to Realm. for example, class Book: Codable { var name: String = "" var author: String = "" var tags = [String]() } Consider the above class conforms to Codable, if store this class to Realm, it needs to use List<Object> type instead of [String] class Book: Object, Codable { @objc dynamic var name: String = "" @objc dynamic var author: String = "" var tags = List<Tag>() required convenience init(from decoder:

How to backup Realm DB in Android before deleting the Realm file. Is there any way to restore the backup file?

匆匆过客 提交于 2019-12-18 04:12:44
问题 I am working on an Android application where I will be deleting Realm before copying the new data to Realm. Is there any way I can take backup of the data before deleting it and restore it back if something is wrong when using realm.copyToRealm() ? 回答1: Realm.writeCopyTo might be helpful for this case. You can find doc here. //Backup Realm orgRealm = Realm.getInstance(orgConfig); orgRealm.writeCopyTo(pathToBackup); orgRealm.close(); //Restore Realm.deleteRealm(orgConfig); Realm backupRealm =

Limit Realm results

寵の児 提交于 2019-12-18 04:04:43
问题 How do I limit the amount of objects Realm returns? .findAll returns all rows matching the query and .findFirst returns only the first. But what about something like first 1000? .findAll may return so many rows that it consumes way too much memory. 回答1: The cool thing is that you don't need to worry about that with Realm. The result object returned from a query is lazily loading the objects and its fields when you access them. Your objects are never copied and thus only represented once in

sip response计算方式

可紊 提交于 2019-12-18 03:03:35
sip注册时有四个步骤,   1.客户端向服务端发送不带Authorization字段的注册请求   2.服务端回401,在回复消息头中带WWW_Authorization   3.客户端向服务端发送带Authorization字段注册请求,Authorization字段中的response信息是    根据收到的WWW_Authorization中的信息和本地的一个密码信息计算出来的。   4.服务端会自己计算一个Response值,和客户端发来的对比,一样的会回客户端一个200OK,表示    注册成功。比对不一样回其他错误码给客户端。 Sip invite时(freeswitch)使用时也需要进行md5校验;      response的计算方法:   1)HASH1=MD5( username:realm:passwd)   2)HASH2=MD5(method:uri)   3)response=MD5(HA1:nonce:HA2)   exosip/osip是通过下面的两个函数计算response,该exosip/osip的版本是2-4.1.0。   char HA1[265],HA2[265];   DigestCalcHA1(0, pszUser, realm_.c_str(), passwd, 0, 0, HA1);   该函数通过pszUser,realm,

How to ensure to run some code on same background thread?

左心房为你撑大大i 提交于 2019-12-17 19:24:54
问题 I am using realm in my iOS Swift project. Search involve complex filters for a big data set. So I am fetching records on background thread. But realm can be used only from same thread on which Realm was created. I am saving a reference of results which I got after searching Realm on background thread. This object can only be access from same back thread How can I ensure to dispatch code at different time to the same thread? I tried below as suggested to solve the issue, but it didn't worked

How can I easily delete all objects in a Realm

浪子不回头ぞ 提交于 2019-12-17 18:27:44
问题 I have the choice of doing a migration, but I would prefer to delete everything in my defaultRealm(). How can I do this easily? realm.deleteObject(object) is the only function along with .deleteObjects. I have tried the following code: Method 1 realm.deleteObjects(RLMObject.objectsInRealm(realm, withPredicate: NSPredicate(value: true))) Method 2 realm.deleteObjects(Dog.allObjectsInRealm(realm)) realm.deleteObjects(Person.allObjectsInRealm(realm)) realm.deleteObjects(Goal.allObjectsInRealm

Realm: working with Clean-Architecture and RxJava2

这一生的挚爱 提交于 2019-12-17 18:22:09
问题 A bit of context, I’ve tried to apply some clean-architecture to one of my projects and I’m having trouble with the (Realm) disk implementation of my repository. I have a Repository which pulls some data from different DataStores depending on some conditions (cache). This is the theory, the problem comes when mixing all of this with UseCases and RxJava2. First I get the list of objects from Realm and then I manually create an Observable of it. But the subscribe (as expected) is executed on a

UITableView with Multiple Sections using Realm and Swift

旧时模样 提交于 2019-12-17 17:49:06
问题 Ok, so I found a lot of information regarding UITableView and multiple sections, however, they are always with strings, arrays, static data, Obj-C or something else with which I am unable to translate to my situation, mainly because I am completely new to developing apps. Any help is greatly appreciated since it has been a little over a month that I have been trying different approaches without success. So I have multiple Dog objects with the following properties: class Dog: Object { dynamic

Proper Realm usage patterns/best practices?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 17:28:23
问题 We're in the process of converting a project to use Realm. We're really impressed so far especially with the Realm Browser (so handy!). As a result, a few questions have come up and we'd like to get some concrete usage patterns down before going any further. Our app is heavily multi threaded (API calls, animations, etc), so keep that in mind when reading the questions, since I know Realm instances cannot be accessed across threads (currently). How worried should we be about repeatedly