You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've added a primary key to an object that didn't have one before, which is based on some of the object's property, one of which has a List<String> data type. However, I am not able to correctly access the list property, hence I can't write the migration for the new primary key.
Expected Results
Being able to parse the elements in the List property.
If my property doesn't contain String, but a custom object instead, I know I can do something along the lines of:
@objcMemberspublicclassCustomObject:Object{dynamicvarfoo:Int=0}
migration.enumerateObjects(ofType:TestObject.className()){ old, new in
guard let old = old,let new = new else{return}letcustomObjects= old.dynamicList("_foobar")
for obj in customObjects {
if let foo =obj["foo"]as?Int{print(foo)}}}
Are primitive data type handled differently in Realm? If so a workaround would be to have a object wrapping the String, but that seems rather wrong.
unsafeBitCast(old![field] as! List<DynamicObject>, to: List<String>.self) will give you a List<String> from the migration object's field. Making this more reasonable is a breaking change for anything currently using that, so I guess it'll have to go into 5.0.
Goals
I've added a primary key to an object that didn't have one before, which is based on some of the object's property, one of which has a
List<String>
data type. However, I am not able to correctly access the list property, hence I can't write the migration for the new primary key.Expected Results
Being able to parse the elements in the
List
property.Actual Results
Not being able to parse the list.
Code Sample
My database object looks as follows:
In my migration block I'm trying to access
_foobar
, but can't seem to get it right:Both
test
andtest2
arenil
.test3
throws some exceptions:The output of
test4
shows the following:There seems to be some technical restriction which prevents me from accessing the actual list properties of my migration object?
Version of Realm and Tooling
Realm framework version:
Realm Object Server version: 3.19.0
Xcode version: 11.2.
iOS/OSX version: 13.2
Dependency manager + version: Carthage 0.34.0
The text was updated successfully, but these errors were encountered: