realm

WatchKit Extension not working under CocoaPods

≡放荡痞女 提交于 2019-12-20 05:52:36
问题 Using iOS-8.3, Xcode-6.3.1 and MacOS-10.10.3 - The CocoaPods (v0.37.1) installation of the RealmSwift (v0.92.3) described here and here basically works, except the WatchKit Extension does not find any Realm keywords. My Podfile looks as follows: xcodeproj 'MyApp.xcodeproj' workspace 'MyApp.xcworkspace' platform :ios, '8.3' source 'https://github.com/artsy/Specs.git' source 'https://github.com/CocoaPods/Specs.git' use_frameworks! def shared_pods pod 'RealmSwift', '>= 0.92.3' end target 'MyApp'

Android: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created

荒凉一梦 提交于 2019-12-20 05:52:05
问题 So inside a IntentService , the app maybe active or inactive , onHandleIntent gets called , where I have placed this below code.This is where I store the data into realm. Realm realm = null; try { realm = Realm.getDefaultInstance(); realm.executeTransactionAsync(new Realm.Transaction() { @Override public void execute(Realm realm) { for (AppItem item : items) { AppItem item2 = realm.createObject(AppItem.class, UUID.randomUUID().toString()); item2.mName = item.mName; item2.mCount = item.mCount;

Realm thread safe object with singleton

谁说胖子不能爱 提交于 2019-12-20 03:44:15
问题 So I have a singleton class that manages the current user that is logged into my application. It looks like this class SessionManager { static let shared = SessionManager() var loggedInUser: User? } The problem is that if I want to get that user object from a background thread, I can't as I get the following exception: 'RLMException', reason: 'Realm accessed from incorrect thread.' After some googling I found Thread Safe Reference's. So I changed my class to be something like this instead:

Saving realm relationships does not persist them

纵饮孤独 提交于 2019-12-20 03:25:05
问题 I have a list of articles. Those articles are inserted by using realm.copyToRealmOrUpdate(); which works perfectly fine. Now each article has an authorId which should not be persisted. Rather I want to find the stored author RealmObject and set its relationship for the article. Author author = realm.where(Author.class).equalTo("id", article.getSerializedAuthor()).findFirst(); article.setAuthor(author); Somehow this does not seem to be persisted by realm. The same applies to the image

Why is my Realm object not saving stored values?

坚强是说给别人听的谎言 提交于 2019-12-20 02:45:29
问题 I was browsing around looking for a solution to implement a small offline data storage in one of my apps which would be easy and quick to use. Anyways, I came across with Realm to do this. But, I'm getting a problem that everytime I launch my app the content in the database is null. I do all the allocation and call the beginWriteTransaction method. Set my database variable value. Then, I add the object to realm and finally commitWriteTransaction . So, I do an NSLog to see if the value is

How to unit test Realm migrations?

妖精的绣舞 提交于 2019-12-20 01:35:20
问题 Im trying to unit test a migration on Realm. My main question is: how can I maintain different schema versions of a RealmObject so as to be able to create a an instance of the old object, do the migration and then check if it is correct according the new schema version? I started by trying to keep the different schema versions but it wont compile since the objects have the same name, despite being on different packages. 回答1: At Realm we test the migration mechanism by storing old Realm files

Realm do a IN query in android

我怕爱的太早我们不能终老 提交于 2019-12-19 21:47:09
问题 Is is possible to do a "IN" query with Realm in android? I mean, doing the equivalent of "SELECT X FROM X WHERE x IN (...)? Thank you very much in advance! 回答1: The official IN operator (since 1.2.0) works like this: public RealmQuery<E> in(String fieldName, String[] values) { if (values == null || values.length == 0) { throw new IllegalArgumentException(EMPTY_VALUES); } beginGroup().equalTo(fieldName, values[0]); for (int i = 1; i < values.length; i++) { or().equalTo(fieldName, values[i]); }

Android Realm - Passing Realm object using Intent

坚强是说给别人听的谎言 提交于 2019-12-19 16:51:01
问题 I want to pass a realm object from one activity to another. e.g. Intent intent = new Intent(MainActivity.this, Second.class); intent.putExtra("Student", studentObj); // studentObj is a realm object startActivity(intent); And receive it from the Second activity Intent i = getIntent(); student = (Student) i.getSerializableExtra("Student"); but this causes a null pointer exception. java.lang.RuntimeException: Unable to start activity ComponentInfo{testapp.com.tms/tms.testapp.com.tms.view

Android Realm - Passing Realm object using Intent

时光怂恿深爱的人放手 提交于 2019-12-19 16:50:12
问题 I want to pass a realm object from one activity to another. e.g. Intent intent = new Intent(MainActivity.this, Second.class); intent.putExtra("Student", studentObj); // studentObj is a realm object startActivity(intent); And receive it from the Second activity Intent i = getIntent(); student = (Student) i.getSerializableExtra("Student"); but this causes a null pointer exception. java.lang.RuntimeException: Unable to start activity ComponentInfo{testapp.com.tms/tms.testapp.com.tms.view

How can I get unmanaged object from Realm query in Swift?

假如想象 提交于 2019-12-19 07:52:53
问题 In Java, you can get unmanaged objects with this: Realm realm = Realm.getDefaultInstance(); realm.beginTransaction(); dogs = realm.where(Dog.class).lessThan("age", 2).findAll() realm.commitTransaction(); realm.close() How can I do this in Swift with Realm-cocoa ? 回答1: To get an unmanaged object from Realm in Swift you can use init(value: AnyObject) initializer: let unmanagedObject = Object(value: existingObject) BTW in your code sample you don't get an unmanaged object as well, you need to