realm

Xcode debug issues with realm

萝らか妹 提交于 2019-12-13 04:44:15
问题 I'm a little confused as to why p self.session and po self.session are returning different values? Which one should I trust in my debugging? It would appear my object is nil but then it would also appear it isn't. Is my session.messages nil or is it set??? 回答1: Guess i should have read the docs. Debugging Debugging apps using Realm’s Swift API must be done through the LLDB console. Note that although the LLDB script installed via our Xcode Plugin allows inspecting the contents of your Realm

Get data from Realm List<>

空扰寡人 提交于 2019-12-13 04:34:57
问题 So this is how my Realm classes looks like: class Workout: Object { @objc dynamic var date: Date? // Date I did the exercise @objc dynamic var exercise: String? // Name of exercise, example; Bench Press, Squat, Deadlift etc.. // List of sets (to-many relationship) var sets = List<Set>() } class Set: Object { @objc dynamic var reps: Int = 0 // Number of reps for the each set @objc dynamic var kg: Double = 0.0 // Amount of weight/kg for each set @objc dynamic var notes: String? // Notes for

RealmSwift LinkingObjects and Decodable

你说的曾经没有我的故事 提交于 2019-12-13 04:33:12
问题 I have a Realm model class that I need to be Decodable so I can serialize it from JSON and save it to database. Every PortfolioItem is associated with one Product and at some point I need to get to PortfolioItem from Product via inverse relationship. That's why I have LinkingObjects property. The problem is when I try to conform to Decodable protocol. The compiler is giving me an error Cannot automatically synthesize 'Decodable' because 'LinkingObjects<PortfolioItem>' does not conform to

Why do I keep getting the error “no such module 'realmswift'”?

删除回忆录丶 提交于 2019-12-13 04:08:17
问题 The previous answers to this question are over a year old. I've tried them. They don't really work. I have installed the pod for using Realm successfully. I wrote a couple of users with a name and role onto the Realm database that I could see with Realm Studio. I then walked away from my computer for an hour (no one else touched it during this time). When I got back I got the no such module error. I have tried to update the pod file several times through the terminal. I also quit Xcode and

How to bundle a realm file

浪尽此生 提交于 2019-12-13 03:55:39
问题 I'm following the realm documentation on how to bundle a realm file. I've successfully loaded all necessary data into my encrypted file, but I can't seem to compact the file and move it elsewhere. Code // AppDelegate fileprivate func compactRealm() { if let realmPath = Realm.Configuration.defaultConfiguration.fileURL { let destination = realmPath.deletingLastPathComponent().appendingPathComponent("compact.realm") if FileManager.default.fileExists(atPath: realmPath.path) { do { // let

Swift saving multiple images to the filesystem at once, High CPU

社会主义新天地 提交于 2019-12-13 03:55:18
问题 I have the following func, I need to clear out all picture columns in a DB and move to the file system. When I did this all in one go, there was too much memory and it would crash. I switched to a recursive function and do the writes and batches of 20. There are about 6 tables which I need to do this for. There is 2 and half gigs of data in my Realm DB. This gets switched to 40mb after I call my 6 recursive functions, taking images out and compressing Realm. I can see very high memory usage

Setting UserNotification with date from a realm database swift

余生颓废 提交于 2019-12-13 03:52:44
问题 I am trying to create a notification based on date and time specified by a user for an application I am working on. I am able to save user's date and retrieve. I now want a notification to pop up when the user's specified date has arrived just like an reminder thing. I can create a notification with with hard coded values but now retriving from the Real database to pass into the trigger value is what I am unable to do. my codes are specified below func notifcation() -> Void { let calendar =

LazyFilterBidirectionalCollection<Results<datatype>>' to expected argument type '[datatype]'

让人想犯罪 __ 提交于 2019-12-13 03:46:34
问题 After I convert my project from swift 2.3 to swift 3 , I got this error in Realm Filter I can't get filter result in array : func filterUsers(_ searchText: String, completion: (([Lawyer]) -> Void)) { let bgRealm = try! Realm() // Filter the whole list of users let results = bgRealm.objects(Lawyer.self).filter { (cc) -> Bool in cc.name.contains2(searchText) || cc.name.contains2(searchText) || cc.phoneNumber2.contains2(searchText) } print(results) completion(results) } 回答1: filter , map , etc.

Realm, complex linked query

徘徊边缘 提交于 2019-12-13 03:37:40
问题 in the official docs, https://realm.io/docs/java/latest/#link-queries - there's an example how to select owners of "Brown Fluffy" dogs. My questions is, how do I select only those not having Brown Fluffy (and, obviously, those having no dogs at all) I do not see how can one achieve this result by, say, using .not().beginGroup().equalTo(...).equalTo(...).endGroup() (that someone with previous SQL experience would try) Thanks a lot in advance! 回答1: Have you tried .not().equalTo(...).findAll()

Using an overriden static property during initialization

半城伤御伤魂 提交于 2019-12-13 03:34:29
问题 I would like to create a class with a static property that subclasses can override, which would be used to initialize instances. So far, I've tried to accomplish this like this: import Cocoa class A: NSObject { class var staticProperty: String { return "A" } var property: String = A.staticProperty } class B: A { override class var staticProperty: String { return "B" } } This does not work, since B().property still returns "A" . How could I change this code so that property contains the value