数组操作有时会抛出 'Operation is invalid after previous operation'
Array operations sometimes throws 'Operation is invalid after previous operation'
在我的一个解析子类中,我有一个这样的方法:
public void updateCheckpoint(String checkpoint, boolean checked) {
if (checked) {
addUnique(checkedCheckpoints, checkpoint);
} else {
removeAll(checkedCheckpoints, Arrays.asList(checkpoint));
}
}
此更新后立即固定到本地数据存储区。
即使添加 ProgressDialog 以确保固定在更新之间完成,有时也会抛出 Operation is invalid after previous operation
。
是否有更健壮的数组操作方式?
在解析 documentation under arrays 中它说
"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."
当您从解析对象中添加和删除时,它会抛出错误 "Operation is invalid after previous operation"。为避免此错误,首先将新值添加到数组,保存对象,删除旧值,然后再次保存。
最初,仪表板上数组的值显示为 (undefined)
。如果您手动将其更改为 (null)
并尝试添加它。它会抛出这个错误。
在我的一个解析子类中,我有一个这样的方法:
public void updateCheckpoint(String checkpoint, boolean checked) {
if (checked) {
addUnique(checkedCheckpoints, checkpoint);
} else {
removeAll(checkedCheckpoints, Arrays.asList(checkpoint));
}
}
此更新后立即固定到本地数据存储区。
即使添加 ProgressDialog 以确保固定在更新之间完成,有时也会抛出 Operation is invalid after previous operation
。
是否有更健壮的数组操作方式?
在解析 documentation under arrays 中它说
"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."
当您从解析对象中添加和删除时,它会抛出错误 "Operation is invalid after previous operation"。为避免此错误,首先将新值添加到数组,保存对象,删除旧值,然后再次保存。
最初,仪表板上数组的值显示为 (undefined)
。如果您手动将其更改为 (null)
并尝试添加它。它会抛出这个错误。