If You Test Using realm.io Object, You Should Use RLMRealm.inMemoryRealmWithIdentifier
TOC
In test, You should use inMemoryRealmWithIdentifier
If you test using realm.io object, you should use RLMRealm.inMemoryRealmWithIdentifier.
I don’t know why, but I got error many times when I wrote some unit test by using realm.
The error is “swift_dynamicCastClassUnconditional”.
I struggled a lot, finally I got a solution.
First of all, below is my code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
This class has static params realm, and when I test write, I set realm object.
But, I notice that I have to new realm object when I do test.
So, I changed my test code to use
1 2 |
|
This worked fine.
About realm
Realm is maybe so fast but I think this is quite difficult to use.
Because I already had a lot of time to use it, actually I’m a cocoa beginner.
The cost of studying it is quite high. but I don’t know how difficult coredata is, so I cannot judge which one is better.