realm

RealmSwift initializer: self used before super.init call

﹥>﹥吖頭↗ 提交于 2019-12-08 10:19:40
问题 import RealmSwift import Realm public class Card : Object { var username : String var firstName : String var lastName : String init?(dictionary: [String:Any]?) { guard let dictionary = dictionary , let username = dictionary["username"] as? String else { return else} self.username = username self.firstName = firstName self.lastName = lastName } required public init() { fatalError("init() has not been implemented") } required public init( realm: RLMRealm, schema: RLMObjectSchema) { fatalError(

Android Realm Handling Primary Key in Relational Object

旧巷老猫 提交于 2019-12-08 09:57:35
I have two objects: MailBox and Email . Each Receiver has many Emails . public class MailBoxRealmModel extends RealmObject { @PrimaryKey private long id; private String name; private String mailboxId; private RealmList<EmailRealmModel> emails; } public class EmailRealmModel extends RealmObject { @PrimaryKey private long EmailId; private String Name; private String Text; private String Tag; private int Type; private String Time; private int Status; } How can one use **realm.insertOrUpdate** when adding email to MailBoxRealmModel? EmailRealmModel email = new EmailRealmModel(); email.setMessageId

Filter by day from NSDate in Realm, Swift

ε祈祈猫儿з 提交于 2019-12-08 08:28:27
问题 So, I put NSDate in Realm model: class GeneralList: Object { dynamic var createdAt = NSDate() dynamic var notes = "" } How to get, for example, all 'notes' in 27.03.2016 ? 回答1: You can implement this function, from Rafael's answer private func createMessageRealmModelFromIncomingMessage(incomingMessage: MessageRestModel) -> MessageRealmModel { let messageRealmModel = MessageRealmModel() messageRealmModel.id = incomingMessage.id! messageRealmModel.messageType = "CHAT_MESSAGE" messageRealmModel

Realm data Insertion took over 7mins for big size json

孤者浪人 提交于 2019-12-08 08:26:35
问题 I use Alamofire to download big json data which was about around 7MB and use RealmSwift to store data at realmobject and SwiftyJSON to parse.My realm object insertion after it finished download the json seems really slow at insertion.Was something wrong with my bad code?Please guide me. First of all I will show simplest Json : { { "Start" : "40000", "End" : "1000000", "Name" : "Smith", "Address" : "New York" },{...},more than 7000 records... } Here is my AlamofireAPI Protocol import

RLMException when trying to perform Realm transaction with Grand Central Dispatch

浪子不回头ぞ 提交于 2019-12-08 08:18:26
I have these two declared as globals in my AppDelegate var realmdb: RLMRealm! var realmQueue = dispatch_queue_create("com.pesto.realmdb", DISPATCH_QUEUE_SERIAL) In my application(_, didFinishLaunchingWithOptions: _) I set a reference of defaultRealm to my global realmdb like so: dispatch_async(realmQueue) { realmdb = RLMRealm.defaultRealm() } In another class in my code I have this method: private func handleChatMessage(message: PSTChatMsg) { // check if there is a channel environment for this message PSTChatHelpers.getChannelEnvironmentForChannelName(message.channel) { channelEnvironments in

How to use Realm database with Java 8 features

泪湿孤枕 提交于 2019-12-08 08:05:55
问题 I am new to using Realm database for Android. I modified my gradle files to include the Jack toolchain so that I could use Java 8 language features. I also modified the gradle files to install the Realm plugin. When I synced the project gradle files, I received the following error: Error:Could not find property 'options' on task ':app:compileDebugJavaWithJack' . The two modifications work fine on their own, but for some reason I cannot have both at the same time. I would very much appreciate

Inverse Relationships and UI-Update not working?

早过忘川 提交于 2019-12-08 05:47:23
问题 I am currently working on a messenger application. Therefore I use realm to store the Data on the device. My app contains a Page to represent all Chatthreads in a Listview. Therefore I binded the ListView to an IRealmCollection. If I change Properties inside the Messagethread I can see that the Litview is updating accordingly. But when I insert a Message into the thread the UI doesn't. public class Messagethread : RealmObject { [PrimaryKey] public string Guid { get; set; } public IList<User

How can I use Realm with newly released versions of Xcode that include new versions of Swift?

允我心安 提交于 2019-12-08 05:22:36
问题 I just updated to Xcode 9 last week, and I've been looking for a way to get around this error: Module compiled with Swift 3.1 cannot be imported in Swift 4.0 Each time a new version of Xcode is released that includes a new version of Swift, I have to wait for the RealmSwift project to be updated in order to build and run my project. I am aware that this has to do with Swift's ABI stability, but I also see others who seem to know how to get around this until a compatible version of Realm comes

Crash when saving data to Realm in background thread. | iOS | Swift 4.2

ⅰ亾dé卋堺 提交于 2019-12-08 05:04:26
问题 DispatchQueue.global(qos: .background).async { RccContactController.shared.updateDbForAppUsers(contactModels: contacts) } DispatchQueue.global(qos: .background).async { RccContactController.shared.updateSyncStatus(lastCount : lastIndex) DispatchQueue.main.async { ContactDataStore.shared.updateContacts(withAppUsers: contacts) if let safeDelegate = RccContactController.shared.delegate { safeDelegate.syncedPhonebookContact(contacts: restContacts, appUsers: cont) } } } What's happening above:

React Native Realm Project Structure

蓝咒 提交于 2019-12-08 05:02:38
问题 What's the best way to implement realm in react native(project structure), when you have multiple webAPI methods and tables to store. I'm doing the following is this a right approach or not? If not kindly suggest or provide any link. created a model folder - each js file in this folder have a model class extended with RealmObject. Created a folder for asynchronous tasks - each js file in this folder Calls web api and write data in Realm objects. Every webapi function has a sperate js file.