我在Realm上遇到了一些Result对象的问题。 我有一个类型' Offer'的集合,在三个不同的视图控制器中,我有三个不同的查询来提供Realm集合,具体取决于Offer属性。 '优惠'每个用户的对象都不同,因此,当用户注销时,我会清除所有会话数据,包括此集合 当用户再次登录(关闭或不关闭应用程序)时,将重新加载所有集合并收到此异常:
malloc: *** error for object 0x208a7614: incorrect checksum for freed object - object was probably modified after being freed.
我重新加载每个集合的方式是:
首先如果本地数据库上有可用的优惠,我会加载它们。
之后,我从远程请求优惠,当我收到优惠时,我会从本地删除所有优惠并添加所有新优惠。
最后我将它们保存在Realm上,我从Realm(使用RxRealm)接收变更集,然后在CollectionView上进行所有更改(使用 performBatchUpdates )。
我做'交换'的方式在重装后的领域是:
do{
try realm.write(){
realm.delete(andRemove)
realm.add(offers, update: true)
}
}
ChangeSet的应用方式如下:
func applyChangeset(deleted:[Int], inserted:[Int], updated:[Int], animationStyle:UITableViewRowAnimation = .automatic) {
self.performBatchUpdates({
self.deleteItemsAtIndexPaths(deleted.map { IndexPath(row: $0, section: 0) }, animationStyle: animationStyle)
self.insertItemsAtIndexPaths(inserted.map { IndexPath(row: $0, section: 0) }, animationStyle: animationStyle)
self.reloadItemsAtIndexPaths(updated.map { IndexPath(row: $0, section: 0) }, animationStyle: animationStyle)
}, nil)
}
以下例外在applyChangeset方法的最后一行上升。
我知道当我尝试重新加载该集合时会出现问题,因为如果我不从远程请求优惠,那么它的效果非常好。
它会发生什么?
此致
编辑:Backtrace