realm

Realm Swift: always put nil values last in sort

空扰寡人 提交于 2019-12-19 06:17:29
问题 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

Realm Swift: always put nil values last in sort

我是研究僧i 提交于 2019-12-19 06:17:04
问题 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

How does the size of a realm-file develop?

纵然是瞬间 提交于 2019-12-19 04:13:05
问题 How does the size of a realm-file develop ? To start with: I have a realm-file with several properties and one of them being an array of 860 entries and each array-entry consists of a couple of properties again. One array-property states the name of the entry. I observed the following: If the name-property sais "Criteria_A1" (until "Criteria_A860") - then the realm-file is 1.6 MB big If the name-property sais "A1" (until "A860") - then the realm-file is only 786 kB big Why is the extra

How to truncate all tables in realm android

寵の児 提交于 2019-12-19 02:39:08
问题 Hi im trying to truncateall tables in android when a user logs out. im using realms default path only. realm = Realm.getInstance(getApplicationContext()); public void clearDB() { Realm.deleteRealmFile(instance); } 回答1: Update Use realm.delete(Foo.class) instead as clear() is deprecated. From 0.91.0 all @Deprecated methods will be removed. Christian from Realm here. That approach will work as long as you have closed all open Realm instances. Another approach is clearing the tables you want

How to get a standalone / unmanaged RealmObject using Realm Xamarin

自古美人都是妖i 提交于 2019-12-18 21:51:47
问题 Is there a way that when I read an object from Realm that it can become a standalone or unmanaged object? In EF, this is called no tracking. The usage for this would be when I want to implement more business logic on my data objects before they are updated on the persistent data storage. I may want to give the RealmObject to a ViewModel, but when the changes come back from the ViewModel, I want to compare the disconnected object to the object in the datastore to determine what was changed, so

Shiro 身份验证

梦想与她 提交于 2019-12-18 21:44:04
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 身份验证 ,即在应用中谁能证明他就是他本人。一般提供如他们的身份 ID 一些标识信息来表明他就是他本人,如提供身份证,用户名 / 密码来证明。 在 shiro 中,用户需要提供 principals (身份)和 credentials (证明) 给 shiro ,从而应用能验证用户身份: principals :身份,即主体的标识属性,可以是任何东西,如用户名、邮箱等,唯一即可。一个主体可以有多个 principals ,但只有一个 Primary principals ,一般是用户名 / 密码 / 手机号。 credentials :证明 / 凭证,即只有主体知道的安全值,如密码 / 数字证书等。 最常见的 principals 和 credentials 组合就是用户名 / 密码了。接下来先进行一个基本的身份认证。 另外两个相关的概念是之前提到的 Subject 及 Realm ,分别是主体及验证主体的数据源。 2.2 环境准备 本文使用Maven构建,因此需要一点Maven知识。首先准备环境依赖: Java代码 <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version> 4.9

Shiro多realm验证失败抛出错误异常

可紊 提交于 2019-12-18 21:16:44
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 使用Shiro时,采用默认验证策略AtLeastOneSuccessfulStrategy,在有多个realm验证下,如果有realm抛出异常后原始异常会被覆盖,导制部份异常显示非原始错误异常信息; 但因为有其它场景,又不能直接更改为AllSuccessfulStrategy(也就是所有Realm验证全部都要通过)。在阅读Shiro源码后,在没有其它合适的办法下,因此只好自行扩展一个MyModularRealmAuthenticator验证类; 增加此验证子类的目的是为了解决在多个Realm下,其中一个Realm抛异常后,继续验证其它Realm,导致原Realm异常被新的AuthenticationException覆盖问题,无法识别原始异常类型; 参见父类ModularRealmAuthenticator.doMultiRealmAuthentication()方法中的处理逻辑 异常如下: org.apache.shiro.authc.AuthenticationException: Authentication token of type [class org.apache.shiro.authc.UsernamePasswordToken] could not be authenticated by

How to completely remove Realm database from iOS?

本小妞迷上赌 提交于 2019-12-18 15:14:09
问题 Now I get error Property types for 'value' property do not match. Old type 'float', new type 'double' How to clear database or migrate is successfully? 回答1: To completely delete the Realm file from disk and start from scratch, it's simply a matter of using NSFileManager to manually delete it. For example, to delete the default Realm file: NSFileManager.defaultManager().removeItemAtURL(Realm.Configuration.defaultConfiguration.fileURL!) If you want to preserve the Realm file, but completely

How to completely remove Realm database from iOS?

我的梦境 提交于 2019-12-18 15:14:05
问题 Now I get error Property types for 'value' property do not match. Old type 'float', new type 'double' How to clear database or migrate is successfully? 回答1: To completely delete the Realm file from disk and start from scratch, it's simply a matter of using NSFileManager to manually delete it. For example, to delete the default Realm file: NSFileManager.defaultManager().removeItemAtURL(Realm.Configuration.defaultConfiguration.fileURL!) If you want to preserve the Realm file, but completely

Detect if Realm.io db needs migration - if so, destroy it

半世苍凉 提交于 2019-12-18 13:35:38
问题 I'm using Realm for caching over the not-so-long term, and have no need to keep up with schema versions or migrating any time there's a change to a data model. So, instead of crashing anytime there's a change to the data model, how can my app smartly handle the discrepancy by blowing away the default Realm and starting from scratch? Thanks in advance! 回答1: This has been working like a charm for me since Swift 2 introduced try/catch. I just call testRealmFile() from my app delegate at launch,