realm

Retriving stored data in realm Swift

浪尽此生 提交于 2019-12-11 14:33:48
问题 I have a todo application which I am using realm to store data. i have writen the database codes for writing to the database and retrive. I have also worked on this particular project before in as a single page code but now I want to improve it by using the MVC approach. this is my codes. //MARK:- Create Category func createCategory(name: String, color: String, isCompleted: Bool) -> Void { category.name = name category.color = color category.isCompleted = false DBManager.instance.addData

Crashing on writing to realm database

北城余情 提交于 2019-12-11 14:33:31
问题 I have a todo application which I am using realm to store data. i have written the database codes for writing to the database and retrieve. When I input into the database for the first time, everything works well that is the data gets inputted into the database but when I try to input another object into the databse, Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance

Why does adding a convenience init to a Realm object declaration mess with private values?

泄露秘密 提交于 2019-12-11 14:11:59
问题 I have created a Realm object that needs to store an enum value. To do that I use a method outlined in this question which involves declaring a private property of type String, and then declaring another property of type Enum that sets/reads the private property using getters and setters. For ease of reference here is the code for that: @objcMembers class PlaylistRealmObject: Object { dynamic var id: String = UUID().uuidString dynamic var created: Date = Date() dynamic var title: String = ""

Swap two objects in Realm.io database in Swift

China☆狼群 提交于 2019-12-11 13:06:51
问题 In my App I store data in Realm database and display data in UITableView. I add cool feature at table - now I can swap cells by drag and drop. But now I have to add method to DataBase class to swap related objects. I've figured out that Realm is unordered, so I thought about adding one more property: index. But consequently I should raise all logic about indexing items in datamodel(insert at index, remove at index, etc), it seems to me wrong approach. Interesting is there common way to solve

Realm causes my app to crash when trying to build a RealmConfiguration

主宰稳场 提交于 2019-12-11 12:59:53
问题 I'm trying to use Realm as a database for high scores in my app. However, when this line of code is called: realmConfig = new RealmConfiguration.Builder(getActivity().getApplicationContext()).build(); in the Fragment where I'm trying to save the user's score, I get this: FATAL EXCEPTION: main Process: com.tommy.mastersproject, PID: 21387 Theme: themes:{com.android.settings=overlay:com.cyngn.hexo, default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com

Realm null pointer when writing to database

给你一囗甜甜゛ 提交于 2019-12-11 12:58:56
问题 Null pointers should be easy to fix, but I cannot understand why I get NullPointerException here. public static void updateUserCity(String city, Context context) { Realm realm = Realm.getInstance(context); realm.beginTransaction(); RealmQuery<User> query = realm.where(User.class); User user = query.findFirst(); if (user != null) { user.setCity(new City(0, city, city)); // here it crashes } realm.commitTransaction(); } And my stacktrace : java.lang.NullPointerException at io.realm

Realm Migration not working

三世轮回 提交于 2019-12-11 12:22:55
问题 I'm getting a crash on my App Store update, the migration is handled and even when I see the code Block is being executed I get the Following migration error 'RLMException', reason: 'Migration is required for object type 'LLCachedObject' due to the following errors: - Property 'resultType' has been added to latest object model.' This is how I'm handling the Migration [migration enumerateObjects:LLCachedObject.className block:^(RLMObject *oldObject, RLMObject *newObject) { if (oldSchemaVersion

Missing argument for parameter #1 in call when setting initial value

时光总嘲笑我的痴心妄想 提交于 2019-12-11 12:09:17
问题 I'm trying to set current locale country as initial value: class Location: RLMObject { dynamic var country = currentCountry() func currentCountry() -> String!{ let locale = NSLocale.currentLocale() let countryCode = locale.objectForKey(NSLocaleCountryCode) as String let countryName = locale.displayNameForKey(NSLocaleCountryCode, value: countryCode) return countryName } } 回答1: The problem is that country is an instance variable and currentCountry is an instance function as well. When you want

perform realm migration for multiple .realm files

醉酒当歌 提交于 2019-12-11 12:04:58
问题 i have multiple realm files, (one per user logged into my app) and i need to run a migration for each realm file in the file system RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration]; config.schemaVersion = 1; config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) { if (oldSchemaVersion < 1) { //do the same changes for all file.realm in the filesystem } }; [RLMRealmConfiguration setDefaultConfiguration:config]; [RLMRealm defaultRealm]; how can

How to Log Out from Keycloak from Django Code

偶尔善良 提交于 2019-12-11 11:40:51
问题 Can not log out from keycloak IDP from inside of Django app code. All stackoverflow answers did not work fo me (most are for older version of the components involved), the same goes for the keycloak documentation. Recently we have implemented keycloak-based athentication for our Django-based website. Works fine for auth. The app is build by docker, three containers: the website on port 8000, keycloak db (postgres image), keycloak (jboss/keycloak image) on port 8080. Now I have to add "Logout"