在Realm iOS上更新嵌套对象的值

时间:2018-08-18 11:03:21

标签: ios swift realm

下面是我从服务器获取并保存到领域DB的数据,当我尝试更新 scheduler_data 值和 stop 值,但它们没有更新时

(
 {
    "form_id" = 3703;
    id = 180;
    "parent_id" = 0;
    "scheduler_data" =     {
        repeat = 7;
        "schedule_for" = task;
        "start_date" = "2018-08-17T11:55:41.867Z";
        "start_time" = "2018-08-17T11:59:44.289Z";
        stop =         {
            field = COL1;
            operation = "equal_to";
            value = "time";
        };
    state = 58;
    territory = GHTY67;
}
)

此处是用于更新Value的代码

SaveTaskDatabase is the table name

for saveData in realm.objects(SaveTaskDatabase.self).filter("unq_id == %@",taskUni_ID){
            try! realm.write {
                saveData.scheduler_data?.stop?.operation = "add"
                saveData.scheduler_data?.stop?.field = "muliple"
                saveData.scheduler_data?.stop?.value =  "baseOnValue"
            }
        }

0 个答案:

没有答案