realm

How to query List<Int> on Realm Swift

久未见 提交于 2019-12-11 17:42:46
问题 How can I filter out the RealmFilter.objectIds that has a given Int? func delete(ids: [Int]) { let filterResultsToDelete = realm.objects(CRMRealmFilterResult.self).filter("ANY objectIds IN %@",ids) //Crashes } class RealmFilterResult : Object { @objc dynamic var filterId: Int = 0 let objectIds = List<Int>() override static func primaryKey() -> String { return "filterId" } } 回答1: This may not be at all what you want but it was a good exercise. Maybe this will help. Let me re-state what I think

Pass A Generic Codable Type as Parameter to a Method for Saving to Realm

ⅰ亾dé卋堺 提交于 2019-12-11 17:04:53
问题 I am trying to create a generic method for decoding some JSON data. I need to cast the JSON data into Objects for later saving in Realm. For example: Getting the makes, models, colors, and body types of vehicles. In each of my JSON calls to the results are formatted exactly the same (See my structs at the end of the question). For brevity, I am only showing you Makes and Models, but Colors and Body Types are exactly the same, just with the name changes. I currently have four methods that I

Cocoapod RealmSwift runtime error: `dyld: Library not loaded: @rpath/Realm.framework/Realm`

一曲冷凌霜 提交于 2019-12-11 17:00:29
问题 I have a project that used to work fine on the device but it started failing after I have re-installed cocoapods. The weird thing is I don't get the problem while running in the simulator. I was also able to replicate the same problem with a completely new project. The exact error was: dyld: Library not loaded: @rpath/Realm.framework/Realm Referenced from: /var/containers/Bundle/Application/34C8D121-9724-4C73-9B62-6F8932E5BFD7/myapp.app/myapp Reason: no suitable image found. Did find:

Realm annotation processor error not picking up

末鹿安然 提交于 2019-12-11 16:58:14
问题 I have been getting the error about the annotation processor for the Realm library fails to load, am I missing something? Where do I add it in or what should I do? This is the error I get: "Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - realm-android-0.82.1.jar (io.realm:realm-android:0.82.1)" Please help. App.Gradle apply plugin:

Will Realm still be able to save the data while user has locked iPhone?

情到浓时终转凉″ 提交于 2019-12-11 16:57:30
问题 I am trying to save some data to Ream database while users have locked their iPhone. Thie data may be the location coordinate which produced by background location updates. If realm can't do it. Could Core Data do it? This is how I do it in code: - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations { NSLog(@"didUpdateLocations: %@", locations); if (locations.count > 0) { CLLocation *location = locations.firstObject; if (location

Realm with huge data

心不动则不痛 提交于 2019-12-11 16:29:27
问题 I had an issue with a realm's database, everything work fine but the problem is the size of data, I found more than 300 Mo every time I use my application, I close all the instance of realm, I clear tables in the beginning to be sure that the database is empty but always the size become bigger every time I run the application. I use the version 0.80 because I use some custom methods. 回答1: Realm is what is called a MVCC Multi-version Concurrency Control database. This means that multiple

Store values in realm

旧时模样 提交于 2019-12-11 15:49:47
问题 I am creating a fitness journal app, and I store workout values in realm this this: I am sorting the workouts using date. I want to accomplish something new, where I can have different weight and reps each set on the same exercise. It is based on this design: I think the database has to bee something like this, but not sure: 23.11.2019 Barbell Bench Press Set 1 KG: 90 Reps: 5 Set 2 KG: 87,5 Reps: 6 Triceps Pushdown Set 1 KG: 110 Reps: 6 Set 2 KG: 110 Reps: 6 Set 3 KG: 112,5 Reps: 5 Any tips

Realm query Object property field by its property

非 Y 不嫁゛ 提交于 2019-12-11 15:47:52
问题 I'm developing an application for iOS using Swift and chose Realm as a database solution for it. I asked one question about Realm and now I have another. Suppose we have a schema like this: class Person: Object { dynamic var id: String = NSUUID().UUIDString dynamic var name: String? dynamic var cars: Car? class Car: Object { dynamic var name: String? I have one class (Person) that contains any number of objects of another class (Car). Car that are "linked" with the Person has some properties

RLMException “Realm at path ' ' already opened with different encryption key” after writeCopy(toFile:,encryptionKey:)

可紊 提交于 2019-12-11 15:17:30
问题 I'm trying to change encryption key for my Realm database using writeCopy(toFile:, encryptionKey:) , like below: public static func updateEncryption(forNewKey newKey: String, withOldKey oldKey: String, completion: (() -> Void)) { let defaultURL = Backup.realmContainerURL let defaultParentURL = defaultURL.deletingLastPathComponent() let compactedURL = defaultParentURL.appendingPathComponent("default-compact.realm") let oldKeyData = oldKey.pbkdf2SHA256(keyByteCount: 64) let newKeyData = newKey

Improve the speed of a realm query in react-native?

て烟熏妆下的殇ゞ 提交于 2019-12-11 15:15:30
问题 I have something like the following code in my react native app to set up mock/test data for performance tests. realm.write(() => { const max = 120; for(let x=1; x<=max; x++) { realm.create('Product', {productId:x}); } for(let x=1; x<=max; x++) { for(let y=x; y<=max; y++) { for(let z=y; z<=max; z++) { realm.create('Compatibility', { result: 'Y '+x+' '+y+' '+z, products: [ realm.objects('Product').filtered('productId = '+x)[0], realm.objects('Product').filtered('productId = '+y)[0], realm