数组操作有时会抛出“上次操作后操作无效" [英] Array operations sometimes throws 'Operation is invalid after previous operation'

查看:19
本文介绍了数组操作有时会抛出“上次操作后操作无效"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个解析子类中,我有一个这样的方法:

In one of my parse subclasses I have a method like this:

public void updateCheckpoint(String checkpoint, boolean checked) {
    if (checked) {
        addUnique(checkedCheckpoints, checkpoint);
    } else {
        removeAll(checkedCheckpoints, Arrays.asList(checkpoint));
    }
}

此更新后会立即固定到本地数据存储.

This update is immediately followed by a pinning to the local datastore.

即使在添加ProgressDialog以确保在更新之间完成固定时,有时也会抛出Operation在前一个操作后无效.

Even when adding a ProgressDialog to ensure that the pinning has completed between updates, then sometimes the Operation is invalid after previous operation is thrown.

有没有更健壮的数组操作方式?

Is there a more robust way of doing array operations?

推荐答案

在 Parse 数组下的文档 它说

In the Parse documentation under arrays it says

请注意,目前无法在同一个保存中以原子方式从数组中添加和删除项目.您必须在每种不同类型的数组操作之间调用保存."

"Note that it is not currently possible to atomically add and remove items from an array in the same save. You will have to call save in between every different kind of array operation."

当你添加和删除你的解析对象时,它会抛出错误上次操作后操作无效".为避免此错误,首先将新值添加到数组中,保存对象,删除旧值,然后再次保存.

When you both add and remove from your parse object, it will throw the error "Operation is invalid after previous operation". To avoid this error first add the new values to the array, save the object, remove the old values, then save again.

这篇关于数组操作有时会抛出“上次操作后操作无效"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆