realm

InMemory Realm Threading in Swift

邮差的信 提交于 2019-12-12 19:22:04
问题 I'm trying to use in memory realm to store some objects. I usually save objects in a secondary thread and ask for objects on main thread . I also need to have a strong reference to the in memory Realm, in order to avoid data loss. static private var _strongInMemoryRealm: Realm? = { return VideoObject._inMemoryRealm }() static private var _inMemoryRealm: Realm? { get { var realm: Realm? = nil let config = Realm.Configuration(inMemoryIdentifier: "InMemoryRealm") do { realm = try Realm

How do I make a write operation in Realm (iOS) synchronous?

◇◆丶佛笑我妖孽 提交于 2019-12-12 18:40:51
问题 As part of an two step analysis process, I need data to be written to the persistent storage prior to the second step beginning. If I do this asynchronously via fina grain notifications its a bit messy. It would be great two do it in-line in one function. Is it possible to make a Realm().write { } opperations synchronous? The second step will need to read this data back. 回答1: Realm.write(_:) is synchronous. 来源: https://stackoverflow.com/questions/38082770/how-do-i-make-a-write-operation-in

Realm React Native - Migration is required: Target type 'string' doesn't exist for property 'emailAddresses'

允我心安 提交于 2019-12-12 17:37:06
问题 I am building a small app with React Native and want to use Realm for persistency. I defined the following schema for a Person : const personSchema = { name: 'Person', properties: { familyName: {type: 'string', optional: true}, givenName: {type: 'string'}, middleName: {type: 'string', optional: true}, emailAddresses: {type: 'list', objectType: 'string'}, } } export class Person {} Person.schema = personSchema The information as to how a Realm schema needs to be defined can be found in the

Unrecoverable error. mremap(): failed: Out of memory in io_realm_internal_SharedGroup.cpp line 188

本秂侑毒 提交于 2019-12-12 14:21:44
问题 I have implemented Realm as my DB, and in my app I run a service on the phone contacts for checking any change in my phonebook. The service works for like 3 to 4 changes and then the app crashes with this error in my logcat. Unrecoverable error. mremap(): failed: Out of memory in io_realm_internal_SharedGroup.cpp line 188 Here's my code: public static void refreshingContactsDB() { createCountryDetailsArrayModel(); TelephonyManager tm = (TelephonyManager) ApplicationController.getInstance()

How to correctly use shouldCompactOnLaunch in RealmSwift

风格不统一 提交于 2019-12-12 13:33:50
问题 The example in the documentation (https://realm.io/docs/swift/latest/#compacting-realms) is not very clear to me, as I don't know if the compaction could be called all the time during app use or only once at startup. Is the implementation below correct or would it be better to make a separate config including shouldCompactOnLaunch to call once on app launch. If I add shouldCompactOnLaunch to the default configuration I see the block being called every time I create a realm instance. Realm

Read from realm.io and add to listview

≯℡__Kan透↙ 提交于 2019-12-12 13:25:43
问题 I want to use Realm.io to save data and then display each item in a listview. Here is how I have create the database (I think): config = new RealmConfiguration.Builder(this) .name("timeLog") .schemaVersion(42) .build(); realm.setDefaultConfiguration(config); Then after this when I save my data I do the following: Realm realm = Realm.getDefaultInstance(); realm.beginTransaction(); timeData logTime = realm.createObject(timeData.class); logTime.setWorkedHours(timeTotal); realm.commitTransaction(

Realm Error: Property requires a protocol defining the contained type

怎甘沉沦 提交于 2019-12-12 13:03:45
问题 I have the following model and I'm using Realm : @interface GUIRoutineModel : GUIModel # GUIModel is a subclass of RLMObject @property (nonatomic, retain) NSString *dateCreated; @property (nonatomic, retain) NSString *dateModified; @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *type; @property NSInteger userId; @property int routineId; #also have same issue using NSInteger @end When I call: // Persist to Realm DB RLMRealm *realm = [RLMRealm defaultRealm]

How to find Realm file location of a Mac App

人盡茶涼 提交于 2019-12-12 12:24:17
问题 First of all, I am very new to Realm ecosystem. I have tried this in AppDelegate 's applicationDidFinishLaunching method, print("Realm Path : \(realm.configuration.fileURL?.absoluteURL)") But it gave me error because, I have added some new properties to the realm object, which produced conflicts with the old schema and crashed the app before even printing this. If you are interested in the crash log. But it has nothing to do with the main question, right? fatal error: 'try!' expression

Realm.io can't get examples to work

a 夏天 提交于 2019-12-12 12:19:40
问题 I'm failing to get started with Realm.io, I've tried it in my own project aswell as with the IntroExample. When i try to look up something, i get: java.lang.IllegalStateException: Mutable method call during read transaction. When i try to store something, i get: io.realm.exceptions.RealmException: Could not find the generated proxy class I seem to have a fundamental flaw somewhere. apply plugin: 'com.android.application' android { compileSdkVersion 19 buildToolsVersion "20.0.0" defaultConfig

How to handle error with Realm during writing?

点点圈 提交于 2019-12-12 11:05:57
问题 I'm used to working with SQL database, I'm new to Realm and, so far, I'm really impressed by the ease of use of this new mobile database. But there is something that I really don't undestand: how to handle error throwing? Take this simple example: I want to store in a Realm DB some market stocks. Each stock has a "symbol" as a unique identifier: APPL for Apple Inc, TSLA for Tesla Motors Inc, etc. I believe it would make sense to declare these symbols as primary keys, since it's not possible