realm

Perform migration by adding List() and another model class

ぐ巨炮叔叔 提交于 2019-12-01 05:08:46
问题 I have the following models class Area: Object { // Specify properties to ignore (Realm won't persist these) // override static func ignoredProperties() -> [String] { // return [] // } dynamic var id = 0 dynamic var name = "" override static func primaryKey() -> String? { return "id" } } class Region: Object { // Specify properties to ignore (Realm won't persist these) // override static func ignoredProperties() -> [String] { // return [] // } dynamic var id = 0 dynamic var name = "" override

Realm for Android with Kotlin - Cannot change Dependencies of Configuration after it has been included in dependency resolution

巧了我就是萌 提交于 2019-12-01 04:51:46
问题 I am trying to get Realm to work in my project. I have Kotlin with version 1.2.51 and Instant Run disabled. In my project build.gradle file I added the following dependency: classpath "io.realm:realm-gradle-plugin:5.4.0" In my App build.gradle file I applied the Realm plugin as explained in the tutorial: apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'realm-android' When I am trying to

Share Realm Data with WatchOS

白昼怎懂夜的黑 提交于 2019-12-01 04:20:11
问题 In my project I want to use one Realm Database with my iOS 10 application and my watchOs 3 application at the same time. So what I did was adding the frameworks to the embedded binaries for the three different targets. This happened to work very well but the watchKit extension doesn't seem to recognize the objects that I created within the iOS environment. How is it possible to have a shared Realm Database between those two devices? 回答1: Update: Okay, thanks to chrisamanse's heads-up, I did

How to achieve the following in Realm for android

感情迁移 提交于 2019-12-01 04:04:14
In my applications, I usually have a loader that loads the data from sqlite and then passes it on to either the activity or fragment it is attached, from where it is set in the adapter of a absListView which then presents it to the user Since realm states that its objects shouldn't be shared across threads , how can this be achieved without making any db calls from the UI thread? (which would make the app feel sluggish as I hit the db a good amount) Also in the 3 examples - intro , gridView & migration , a number of times db operations are done in the UI thread. Isn't database operations in UI

Realm Swift: always put nil values last in sort

久未见 提交于 2019-12-01 04:04:10
I'm writing an app in Swift 2.2 targeting iOS 8 and using Realm. I allow the user to sort objects based on various optional properties using Results.sorted(_:ascending:) . This works very well for descending sorts but for ascending sorts, nil values are placed first which doesn't look right. Many database systems have a NULLS FIRST/LAST option and with CoreData, it looks like it's possible to subclass NSSortDescriptor . Is there any way to always put nil values last when sorting in Realm? Even if there's only a hacky strategy, that would be appreciated, too. Realm doesn't support custom

RLMObject with Array of NSStrings

人盡茶涼 提交于 2019-12-01 03:29:37
I've been upgrading a project to use Realm as the persistence store and I'm not able to find any documentation on how to use an array of strings in one of my models. The implementation of an Array for a RLMObject is to use an RLMArray where T inherits RLMObject I could make an object that inherits.. property inside which is string... but that seems like quite some overhead to replace an NSArray of strings. Does anyone know the recommended best practice to do this? As of Realm Cocoa 3.0 you can simply do RLMArray<RLMString> *array; and no longer need the wrapper object type. In older versions

Android, using Realm singleton in Application

这一生的挚爱 提交于 2019-12-01 03:24:16
问题 I'm new to Realm, I'm wondering whether it's good practice to just have one Realm instance in Application object, use it across all cases needed in the app, and only close it in onDestroy of the Application class. Thanks 回答1: There is nothing inherently wrong with keeping the Realm on the UI thread open and not closing it (note there is no OnDestroy on Application ) However you should keep the following in mind: 1) Realm can handle the process getting killed just fine, which means that

How can I use Realm with Swift 4?

不想你离开。 提交于 2019-12-01 03:22:42
I'm trying to run my current project in the new Xcode 9 beta, but when I do so it says Module compiled with Swift 3.1 cannot be imported in Swift 4.0 . How can I solve this problem? I'm not using cocoapods. Update : As of v2.10.1, released 2017-09-14, Realm's prebuilt binaries include frameworks built with Xcode 9 for Swift 3.2 and 4.0. It's no longer necessary to build them yourself. The information below remains relevant to anyone looking to use Realm with prerelease versions of Xcode in the future. If you're currently integrating Realm's prebuilt binaries, you'll need to switch to building

What's wrong with my #if TARGET_OS_SIMULATOR code for Realm path definition?

点点圈 提交于 2019-12-01 03:07:43
I have this code #if TARGET_OS_SIMULATOR let device = false let RealmDB = try! Realm(path: "/Users/Admin/Desktop/realm/Realm.realm") #else let device = true let RealmDB = try! Realm() #endif device bool works fine, yet RealmDB works only for else condition. TARGET_IPHONE_SIMULATOR macro doesn't work in Swift. What you want to do is like the following, right? #if arch(i386) || arch(x86_64) let device = false let RealmDB = try! Realm(path: "/Users/Admin/Desktop/realm/Realm.realm") #else let device = true let RealmDB = try! Realm() #endif As of Xcode 9.3+ Swift now supports if #targetEnvironment

List<Object> Or RealmList<RealmObject> on Realm Android

ぐ巨炮叔叔 提交于 2019-12-01 02:22:30
I need a list<Object> using Realm. I tried RealmList<RealmObject> but it doesn't work because RealmObject is abstract. Christian Melchior Christian from Realm here. You can only save objects that extend RealmObject inside a Realm. This is because Realm is not a schemaless database. We do require a schema and that schema is defined by your objects that extend RealmObject. We use RealmList because it abstracts away the communication with the underlying core database, but it implements the List interface. This means that public class Foo extends RealmObject { private List<Object> objects; // not