天道酬勤,学无止境

realm

Realm.io and asynchronous queries

We are starting to use Realm.io in an android app project. But something that we don't like with the Realm.io API is the absence of any asynchronous way to query the database. In old projects we used DbQuery and Sqlite, so we are used to make the database queries inside threads or AsyncTask's. But is quite disturbing see that in all the examples the queries are made in the UiThread. Isn't this a bad thing for the app performance?. We tried to make the queries inside threads or AsyncTasks but we get an error when we access our model objects back in the UiThread, saying that we cannot access

2021-06-15 07:49:52    分类:问答    android   database   multithreading   android-asynctask   realm

Realm Android javassist.NotFoundException: io.realm.com_example_realmtest_data_SomethingRealmProxyInterface

I was completely new to realm in android, and I started from simple kotlin-project with only one entity which had only one field. open class Something : RealmObject() { @PrimaryKey var id: Long = 0 } I initialized Realm in my Application class: class RealmApp : Application() { override fun onCreate() { super.onCreate() Realm.init(this) val config = RealmConfiguration.Builder().build() Realm.setDefaultConfiguration(config) } } And, of course I added realm plugin: //Project level dependencies { ... classpath "io.realm:realm-gradle-plugin:5.9.0" } //Module level apply plugin: 'realm-android'

2021-06-15 07:03:06    分类:问答    android   kotlin   realm

Should I use Realm Objective-C or Realm Swift in my mixed Objective-C / Swift project?

My project uses Swift and targets iOS 8.0 and newer, but we use some files from our old Objective-C project, and brings in some Objective-C libraries via CocoaPods. Which Realm interface should I use in this project: Objective-C or Swift? I'm confused because of the announcement in the Realm documentation: If you’re looking to use Realm from Objective-C, or from mixed Objective-C & Swift apps please see Realm Objective-C instead. Using both Realm Objective-C and Realm Swift simultaneously is not supported.

2021-06-15 05:23:23    分类:问答    ios   swift   realm

Realm, Swift, Many-to-many relationship

On my API I've got a relationship between Stands and Products. In which stands have products, but products can be found in different stands aswell. I'm trying to replicate this relationship on my iOS-application, using Realm but I can't seem to get it working. The goal of having this relationship is being able to search for Stands that sell particular products. My model: class Stand: Object { dynamic var id : Int = 0 dynamic var name : String = "" dynamic var latitude : Double = 0.0 dynamic var longitude : Double = 0.0 let products = List<Product>() override static func primaryKey() -> String

2021-06-15 04:12:59    分类:问答    ios   swift   realm

@objc redundancy when having @objcMembers private dynamic var?

So I am using Realm with Swift and I marked my class with the @objcMembers keyword however when I tried to make some private variables, Xcode forced me to add @objc beside those private vars. Is this an intended behavior? Seems like it's redundant to me. @objcMembers class MyObject: Object { @objc dynamic private var text: String = String() @objc dynamic private var youtubeLink: String = String() @objc dynamic private var count: Int = 0 dynamic var isFavorite: Bool = false dynamic var currentCount: Int = 0 }

2021-06-14 21:14:55    分类:问答    swift   realm

How can I create a Realm database with initial data for my android app?

I am trying to create a database for my android application using Realm. I need to have data that is pre-populated when the app is installed. Setting a Realm Migration as part of the RealmConfiguration does not run when the version of the database is 0 (defaults to 0 initially). How can I add data the first time the application is setup?

2021-06-14 19:12:16    分类:问答    android   realm

How do i prevent duplicates in RealmSwift List?

How do I prevent adding duplicates to a list in RealmSwift? I have my User as a realm object, but the real data source is a server (simply caching the user locally with Realm). When I get the current user data from my server, i want to make sure that my user stored in realm has all the playlists coming from the server (and that their in sync wrt list of tracks and etc.). I'm worried that if i loop over those lists from the server, appending to myUser.playlists, that I may end up adding the same playlist to the user's list of playlists multiple times. class User: Object { dynamic var name = ""

2021-06-14 17:52:25    分类:问答    ios   swift   realm   realm-list

How can I check my realm schema version without opening the realm file?

The problem we face is we cannot migrate with the new schema version so we want to wipe out all the realm data clean and create a new one instead (for all the user who have schema version less than this new number). But I cannot find a way for me to know this number except only during in the migration block. Is there a way to know this schema version else where?

2021-06-14 14:57:36    分类:问答    ios   realm

Can I use RestKit and Realm.io?

I want to use RestKit, but I already use Realm.io instead of CoreData. Is it possible to use RestKit on top of Realm.io?

2021-06-14 12:12:42    分类:问答    restkit   realm

Realm findFirst() method returns null

I searched and found FindFirst returns null question but no one answered it. As I'm thinking I am doing something wrong, let me explain my problem with more details. I'm working on an app that asks the user to sign in first and then lets the user use the app. My User class looks like this: public class User extends RealmObject { @PrimaryKey @SerializedName("uid") String id; @SerializedName("ufname") String firstName; @SerializedName("ulname") String lastName; String avatar; int sessions; int invites; String nextSessionTime; String nextSessionTitle; @SerializedName("lastlogin") String lastLogin

2021-06-14 09:42:01    分类:问答    java   android   realm