swift,realm,object-object-mapping
So this seems to be the solution how to convert an array of children to my RLMObject Attachment. I'd love some feedback on how wrong I am implementing this and what would be a more proper solution since I feel kinda bad for this: ///Transformer transforming the api's attachment array...
Joe from Realm here. Currently we don't support Arrays of primitive types. It is something that we are discussing and on the road map though. For now your best bet will be to create another RLMObject and then an RLMArray relationship to that, to store your primitive types....
So for now I have solved the problem like this (modifying the model, which I wanted to avoid): I store only the path to the parent, not the full one along with the name. The name gets stored in a different field (to get full path I stitch the two...
ios,objective-c,swift,cocoapods,realm
Alright, here is the full walkthrough: Install dependencies using Cocoapods and the use_frameworks! flag. As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need...
Realm can only store classes that extends RealmObject, so it is not possible to save the android.location.Location class directly. If you require the android Location class for some other API I would create my own Realm Location class that are able to convert it's representation, like so: public class MyLocation...
try this: let idQuery = realm.objects(JournalEntryLine).filter("id = \(item) AND type = 'Debit'") transform id = '\(item)' to id = \(item) because id is an Integer, if you use quotes, il will consider id as a string....
The encryption key is used to encrypt/decrypt the actual file. So it has to be same across all transactions. That is also why you need to find a way to save the key between app restarts as otherwise you cannot access the Realm again. There are some links in our...
Yes, Realm should be able to parse that, but it looks like your naming is not right. Your Doctor class calls it specializationList but in your JSON it is specializations. If you change your Doctor class to the following it should work: public class Doctor extends RealmObject { @PrimaryKey private...
android,multithreading,retrofit,realm
Yeah Disabilities extends RealmObject and is part of the Realm. What you could do is create a new object: Disabilities disabilities = new Disabilities(); And then put the content that's inside the Disabilities in your new object. This works because this object is not in Realm yet....
android,database,list,realm,realm-list
SearchData class has both getIs_favorite() and is_favorite(). In that case, Realm annotation processor overrides only is_favorite(). That's why getIs_favorite() returns always false....
android,ios,documentation,realm
If you look at the top of the webpage that you linked it says: Install in Dash. Dash is an app in App Store: https://itunes.apple.com/ro/app/dash-api-docs-snippets/id458034879?mt=12 that let's you view documentation offline....
Don't use the create new model from the Xcode new file. Create instead a Swift file and write the Realm object yourself. This is how a Realm object looks like in Swift: import RealmSwift // Dog model class Dog: Object { dynamic var name = "" dynamic var owner: Person?...
Create a new ActivityTreeModel object: [[ActivityTreeModel alloc] init], and then set all it's properties as to the one you want to copy, but with the different primary key.
You need to add the object to the realm before adding it to a list because internally Realm will call getId (or whatever method to get it's primary key) in order to add the object to the list. Since it uses proxy methods and the object was not added to...
Well I found a way, by doing something quite silly, any better options?: Class clazz = obj.getClass(); if (clazz.getName().endsWith("Proxy")) { clazz = clazz.getSuperclass(); } I'm 100% sure objects will never end with Proxy ;) in my app....
Create your own class (e.g. MyLatLng) which mimics LatLng structure. Next create static method inside your MyLatLng class which converts MyLatLng object to LatLng object and vice versa. It have to be static because only setters and getters are allowed methods in RealmObject classes.
objectForPrimaryKey() is what you're looking for: Realm().objectForPrimaryKey(Book.self, key: prevBook.nextID). There's no simpler way than filter().first if you need to search for the object by something other than the primary key.
java,android,arraylist,realm,realm-list
Yes, you have to manually box your strings in a StringObject. We'd like to add support for RealmList<String>, RealmList<Integer>, etc., but it's a long way out.
By creating a description property, you're overriding the -description method on NSObject that's used to print an object's contents when using NSLog or println. See http://stackoverflow.com/a/4718806/373262 for more details....
When you download the Realm, you have an Example project. Open it and you have a demo for migration. This is how they do the migration: let migrationBlock: MigrationBlock = { migration, oldSchemaVersion in if oldSchemaVersion < 1 { migration.enumerate(Person.className()) { oldObject, newObject in if oldSchemaVersion < 1 { //...
android,genymotion,eclipse-adt,realm
The answer is in this thread https://github.com/realm/realm-java/issues/705#issuecomment-77466953 Best regards....
java,android,gson,retrofit,realm
On request the callback you're probably getting a List <WorkOrderItem> So I think you need to create your Realmlist <WorkOrderItem> from your list. you need have two Objects WorkOrderItem and other WorkOrderItemRealm extends RealmObject For instance : List<WorkOrderItem> mWorkOrderList... RealmList<WorkOrderItem> mRealmList... //WorkOrderItem need to be a RealmObject ...new Callback<List<WorkOrderItem> mWorkOrderList>()...
Since RealmSwift must be distributed as a dynamic framework, there's no real way to use it on iOS 7. Realm Objective-C should work just fine in Swift, albeit with a less 'native' feel.
ios,multithreading,swift,grand-central-dispatch,realm
I'm pretty sure the crash happens because you're trying to use an article from a "background accessed Realm" in the ReadArticleViewController's viewDidLoad method which is called in the main thread. You cannot access Realm from background to pick an article in your prepareForSegue: method and then use the article...
Hi Joe from Realm here. You are correct, you will need to pull down the JSON then build out your objects manually on the client side. Realm is object graph based so you link objects with objects directly! For example if a person has many dogs, on the server you...
I think you better use Inverse Relationships for ToOne relationship instead. Foo class will be the same. but you will change foo property in Bar class, like the following. class Bar: Object { dynamic var id = 0 dynamic var title = "" //dynamic var foo = Foo() // Reference...
let nextId = realm.objects(Alarm).max("id") as Int? You need to tell Swift what the return type of max() should be at the call site because it varies depending on the type of the property that you name in the string parameter. It needs to be Int? rather than just Int because...
RealmList <Student> results = new RealmList<Student>(); for(Student student : realResultsList){ results.add(student); } However, this is not the most elegant way to do the conversion. ...
If you need Objective-C interop, your best bet is to continue using Realm Objective-c. Since List is a generic type, it can't be represented in ObjC at all.
You'll need to add /path/to/RealmSwift.framework/Frameworks to the “Framework Search Paths” section in Build Settings where /path/to/RealmSwift.framework is the location of the framework. This is because RealmSwift.framework depends on Realm.framework (where the Realm and Realm.Private modules are defined), which is vendored in its Frameworks directory....
algorithm,swift,realm,text-segmentation
In this case, you should use autoreleasepool (see: Use Local Autorelease Pool Blocks to Reduce Peak Memory Footprint) in the loop: while position > 0 { autoreleasepool { var index = advance(string.startIndex, position) ... } } BTW, your code has too many memory copy operations and O(N) operations on String.Index...
Try the following: var findConversations = ShufflePerson.objectsWhere("receiver='\(from)'") var shuf = findConversations[0] as! ShufflePerson self.realm.beginWriteTransaction() shuf.unreadMessage++ self.realm.commitWriteTransaction() The issue, as the exception message said, was that you were modifying the object outside of the write transaction. Doing that mutation inside the transaction should do the trick!...
ios,osx,nsdate,realm,foundation
Option 2 will use less space, but the difference may not be worth caring about in your case. With 5000 entries and Option 1 you'd be looking at 160KB of string data (for short strings, the storage size is rounded up to a power of two for O(1) indexing within...
android,database,web-services,gson,realm
Did it like this and it worked: WSCalls.getData("/api/users/" + user.getId() + "/friends", PSProfileActivity.this, loader, new JsonCallback() { @Override public void onResponse(JSONObject jsonObject) { try { FriendsResponse friendsResponse = JsonUtil.jsonToObject(jsonObject.toString(), FriendsResponse.class); Log.i("","friends response: " + friendsResponse.getFriends()); Realm realm = Realm.getInstance(PSProfileActivity.this); friends = friendsResponse.getFriends(); for (UserRecord friend : friends) {...
That's a current limitation of Realm. It doesn't support polymorphism on relations. If possible, I'd avoid inheritance in this case. You could reach that by altering your object-relational mapping: You could add a further discriminator column to your Base class and have relations to classes which contain further attributes and...
You can simplify that and just do: [myRlmObject allObjects].firstObject ...
I found out that Realm doesn't fully support distinct queries yet. The good news is I also found a workaround for it, on this github issue. Objective-c RLMResults *messages = [Message allObjects]; NSMutableArray *uniqueIDs = [[NSMutableArray alloc] init]; NSMutableArray *uniqueMessages = [[NSMutableArray alloc] init]; for (Message *msg in messages) {...
I believe you can just do it like this var RealmObject = RealmX[0] ...
You should be able to find the information you need here: https://realm.io/docs/java/latest/#migrations Just changing your code to the new definition will work fine, if you have no data stored on disk under the old database schema. But if you do, there will be a mismatch between what Realm sees defined...
I would recommend you, that you use CocoaPods. I did it like you did, with dynamic frameworks. But when I try to submit my application (in Xcode/Organizer) to iTunes Connect. I could not because of nested frameworks, Realm.framework is in RealmSwift.frameworks and that is not "cool" with Apple. So I...
ios,swift,cocos2d-iphone,realm
You might need to explicitly set a default value for the value of damage in EnemyDB. Try changing it to this, and let me know if that works! class EnemyDB : RLMObject { var damage: Int = 0 } ...
Christian from Realm here. The migration API is still in a very experimental state and kinda ugly, so right now the version number always start with 0, and the only way for changing that is through a migration. This means that if you want a fresh install with a different...
From the FAQ section of Realm docs: How big is the Realm library? Once your app is built for release, Realm should only add around 1MB to its size. The releases we distribute are significantly larger (~37MB for iOS & ~2.4MB for OSX) because they include support for more architectures...
Make sure your framework is added to the Embedded Binaries and Embed Frameworks. While this is the first step that you're supposed to do: "Go to your Xcode project’s “General” settings. Drag RealmSwift.framework from the ios/ or osx/ directory to the “Embedded Binaries” section. Make sure Copy items if needed...
You could use static fields or the @Ignore annotation. Adding the @Ignore prevents realm from saving them into the DataBase, and you can still use getters and setters and add these with an interface....
So I fixed it by upgrading to a newer GRUnit version then downgrading agin because GRUnit didn't work anymore and removing pod 'Realm/Headers' with pod 'Realm' and ran pod install again.
That is the proper way of deleting it. You can check the Migration example in the RealmExample project that come with the SDK and see that that's exactly how they do it, so I assume the recommended way. let defaultPath = Realm.defaultPath NSFileManager.defaultManager().removeItemAtPath(defaultPath, error: nil) ...
Realm cannot find the native libraries for some reason. Are you using Android Studio or Eclipse. If you are using Eclipse, note that some extra setup is required as described here: http://realm.io/docs/java/0.79.0/#getting-started
Since you are not actually removing elements that you are iterating over, you can just use a traditional for loop: for (int i = 0; i < mSections.size(); i++) { mSections.get(i).getEvents().clear(); } Note that if you did need to remove elements using an Iterator, you would need to use the...
Christian from Realm here. You can only save objects that extend RealmObject inside a Realm. This is because Realm is not a schemaless database. We do require a schema and that schema is defined by your objects that extend RealmObject. We use RealmList because it abstracts away the communication with...
I ran in the same problem the other day: Basically you should not create "init" methods but you can create "convenience init" methods. In that case you can't call super.init() but you call something like self.init() so in your case above you have to remove override init() and the other...
So problem solved: What I didn't know is the fact, that I guess that the model object is set in all the realms existing in the app no matter whether I have stored it in them or not. The solution was to copy/paste the code RLMRealm.setSchemaVersion... for all the realm...
This happened to me too, a while back! Basically, just reset your your IOS Simulator that you are testing on. Click on "IOS Simulator" menu, then "Reset Contents And Settings" Let me know if this works......
You'll have to wait for us to support Swift 2.0 (#2062) before you can use Realm Swift in your Swift 2.0 project. Because the framework written in Swift which was built in the old version compiler is not able to use in Xcode 7. Therefore, it will be needed to...
java,android,multithreading,realm,event-bus
Realm uses a ThreadLocal cache internally pr. Realm file so it is practically free to call Realm.getInstance() in every activity/fragment/presenter you have. The first call to Realm.getInstance() will cost a little as database has to be opened and the schema verified, but after that it just cost a cache lookup....
You cant use List for that. List for to-many relationships However you can achieve what you want by combining all your strings into one, separated by a character. You use this func componentsSeparatedByString(_ separator: String) -> [AnyObject] afterwards to get your Array back from it....
android,database,parsing,gson,realm
I found the issue: The problem was that I was using: Gson gson = new Gson(); Instead of what I should have used: Gson gson = new GsonBuilder() .setExclusionStrategies(new ExclusionStrategy() { @Override public boolean shouldSkipField(FieldAttributes f) { return f.getDeclaringClass().equals(RealmObject.class); } @Override public boolean shouldSkipClass(Class<?> clazz) { return false; } })...
There was an issue on Realm's GitHub repository about that. Realm Swift's podspec makes use of some brand new CocoaPods features, so you will need to update CocoaPods to at least 0.37.1. Cleaning the cache and the existing installation and re-installing has proven to be helpful in that case: rm...
Implement this function openRealm in AppDelegate and call it in func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { ... openRealm() return true } func openRealm() { let defaultRealmPath = Realm.defaultPath let bundleReamPath = NSBundle.mainBundle().resourcePath?.stringByAppendingPathComponent("default.realm") if !NSFileManager.defaultManager().fileExistsAtPath(defaultRealmPath) { NSFileManager.defaultManager().copyItemAtPath(bundleReamPath!, toPath:...
Having a different set of Object subclasses in each Realm isn't yet supported, but it will come with https://github.com/realm/realm-cocoa/issues/1584.
How about link query in documentation? There is an example: RealmResults<ChatRealm> contacts = realm.where(ChatRealm.class).equalTo("users.id", "some id").findAll(); ...
Christian from Realm here. Currently what you are asking is really not feasible. As others have pointed out there is really only two approaches. 1) Expose a ContentProvider. However that require you to map RealmResults to a Cursor which is not a trivial effort. We are planning on exposing a...
Christian from Realm here. Currently there is unfortunately no other way than the one you found yourself if you don't want to maintain a RealmList<Playlist> field on the Song. That said we have a concept called Backlinks on our TODO which are exactly for use cases like this: https://github.com/realm/realm-java/issues/607
swift,nspredicate,enumeration,realm
Thanks for the clarification. Since collectedSentences is a Realm List object, then deleting it would invalidate the results of the original query, which is what's causing the exception. One way to get around this (Which I've used in my own app before) is to make a static copy of the...
Yep! Realm is a completely offline, local database solution. There's no online component, but if you do decide to, you can sync data from Realm online using third party cloud services like Parse (Or just literally copying the database file to Dropbox). By default, all data saved with Realm is...
That's a current limitation of Realm. Keypath Collection Queries are not yet supported.
Realm currently does not support doing aggregate queries, so there's no one-liner to perform the query you want. Additionally, Realm is unable to query un-persisted properties (as balance is, in this case), because they are not in the database. Your best bet is to manually filter all of the Person...
I found a workaround that requires 2 extra lines of code, and an extra serialisation step. @Inject ObjectMapper mObjectMapper; // I use Dagger2 for DI .... CreditCard creditCard = realm.createObject(CreditCard.class); card.setWhateverField(...); ... // I use Jackson's ObjectMapper to "copy" the original creditCard // to a new temporary instance that has...
I also tried the combination of Realm and Parse. And yes you'll have to sync the data manually between both datasets by creating models for each. But I think writing (almost) the same model classes for both Parse and Realm could be counter-productive. That's why I dropped Realm and used...
Hi Dave there isn't anything built into Realm yet that can do that for you. You will need to use a transformer like Realm-JSON, or Mantle, etc.
java,android,multithreading,realm
If the problem is caused by calling onDataSetChanged and getViewAt from another thread, you can force them to use the same thread, creating your own HandlerThread like this: public class Lock { private boolean isLocked; public synchronized void lock() throws InterruptedException { isLocked = true; while (isLocked) { wait(); }...
android,json,android-volley,realm
Realm currently doesn't support primitive arrays. You JSON has this: "languages" : ["fr", "en"] For Realm to automatically map the JSON to your MyString class it would have to be converted to something like this: "languages" : [ { "str" : "fr"} , { "str" : "en" } ] You...
Realm doesn't support GroupBy yet. Also be aware that beginGroup() is actually the same as parentheses. So your query is actually interpreted as : // SQL pseudo code SELECT * FROM Account WHERE (date = MONTH(date)) In Realm you would have to do something like this to select a single...
Since there was no way to do this directly, I ended up making my own adapter. public class BarAdapter extends ArrayAdapter<Bar> { //code to instantiate the adapter, inflate views, etc } This part was trivial, the only hard work to be done was by curating a query from Foo-->Bar that...
The issue is that Results.filter(_:...) takes arguments of type (String, CVarArgType...) but Results does not conform to CVarArgType. I've just created GitHub issue #1995 to track this. The fix is pretty simple and I'd hope to have a PR up soon to address the issue. In the meantime, you could...
A better way is to do realm.deleteAllObjects on your instance of the realm. More about that here http://realm.io/docs/cocoa/0.90.6/#deleting-objects. This removes all of your objects. If you want to remove one object, you can do realm.deleteObject(object here). There is more on that in the link above as well. Removing the file...
android,class,object,casting,realm
All Realm classes extends RealmObject so you can use generics to accomplish it: public static <T extends RealmObject> void executeInsertInto(final Context context, final T passedObject){ Realm realm = Realm.getInstance(context); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { T itemToWrite = realm.copyToRealm(passedObject); } }); realm.close(); } ...
You can download a device's container for your app from Xcode's "Devices" window with the following steps: Connect your device to your Mac. In the Devices window under Devices, select your device. Under Installed Apps, select the app from the list. From the Action menu (the gear icon), choose a...
I found the solution as and It worked public void updateNewCard(Realm realm, VisitingCardPOJO card) { VisitingCardPOJO toEdit = realm.where(VisitingCardPOJO.class) .equalTo("no", card.getNo()).findFirst(); realm.beginTransaction(); toEdit.setName(card.getName()); toEdit.setAddress(card.getAddress()); realm.commitTransaction(); } ...
android,database,many-to-many,realm
There are several ways to implement many-to-many relationships in Parse. You can use Arrays or Relations depending on the number of related objects. You can read more in Parse's documentation. In Parse Relations, you can add multiple objects in a relation before making a call. Let me take Book and...
In Realm, while you can subclass your RLMObject entities, those subclasses aren't polymorphic. That is to say, you cannot substitute a Person object when you say you're linking to a Contact object, because Realm treats them as entirely separate entities.
ios,block,magicalrecord,realm,completion
the equivalent in Realm is -[RLMRealm transactionWithBlock:]. Since both your MagicalRecord example and Realm's equivalent run in the current thread, the completion block is a bit redundant because it's equivalent to adding code immediately after the call to this method....
It is because you are combining mRealm.createObject() with mRealm.copyToRealmOrUpdate(). These two concepts are really orthogonal. Realm operates with a concept of "managed" and "standalone objects". Standalone objects is objects that are created using the normal new operator and are converted to managed objects when you use one of the mRealm.copyXXX...
Results does not support concatenation, but you can create a GeneratorOf that will yield the sum of the two results, or create an [Object] that is the non-lazy equivalent of that by doing let sum = map(array1) { $0 } + map(array2) { $0} ...
You're looking for this: let realm = Realm() let deletedValue = "two" realm.write { let deletedNotifications = realm.objects(Notifications).filter("value == %@", deletedValue) realm.delete(deletedNotifications) } or perhaps this: let realm = Realm() let serverValues = ["one", "three"] realm.write { realm.delete(realm.objects(Notifications)) // deletes all 'Notifications' objects from the realm for value in serverValues...
Your for should start at 0 and end at array.count - 1. In your case you can just use "<" instead of "<=" i < Int(allShuffle.count). You could also use the fast enumeration and not have any pb with objects count and index: for object in ShufflePerson.allObjects() { let shufflePerson...
The cool thing is that you don't need to worry about that with Realm. The result object returned from a query is lazily loading the objects and its fields when you access them. Your objects are never copied and thus only represented ones in memory/disk. The (current) implementation detail of...
RealmBaseAdapter doesn't work with ExpandableListAdapter (which I am assuming you are using for sections?), so right now your only choice is creating your own implementation. But a RealmResults is also a List so it should work seamlessly with an ArrayAdapter. You can also see more details here: https://github.com/realm/realm-java/issues/978...
As mentioned in the comments, you shouldn't need to import the header in your umbrella header if you are importing it directly in Swift.
I don't believe there is any support officially, but this article may describe some other third party libraries which may be able to achieve what you are after http://blog.matthewcheok.com/working-with-realm/...
Any reason you want to use contains? The below would be more precise: BasicSavedInfoImpl obj = realm.where(BasicSavedInfoImpl.class).equalTo("id", id).findFirst(); if (obj != null) { // success } If you want to use contains the following should work RealmResults<BasicSavedInfoImpl> objs = realm.where(BasicSavedInfoImpl.class).contains("id", id).findAll(); if (objs.size() > 0) { // success } But...
I think it i possible. You can check it out here: http://realm.io/docs/java/latest/#link-queries As per your case, you can try my following code: RealmResults<Doctor> rDoctors = realm.where(Doctor.class) .equalsTo("organization.organizationId", organizationId) .findAll(); return rDoctors; Please let me know if it works for you....