[英]how to fetch all values in attributes using magical Records Library Swift
[英]Magical Record delete all records Swift
我正在嘗試清除 Swift 中 Magical Record 表中的所有行。 我試過了:
DeviceLog.mr_truncateAll()
但這似乎沒有效果。 有人知道如何正確地做到這一點嗎?
提前致謝。
看起來我沒有醒,當我保存時它起作用了。
MagicalRecord.save({ (context) in
DeviceLog.mr_truncateAll(in: context)
}, completion: { (changed, error) in
if let _ = error {
print("Error truncating DeviceLog: \(String(describing: error?.localizedDescription))")
} else {
print("Truncate DeviceLog successful: \(changed)")
print(DeviceLog.mr_countOfEntities())
}
})
或者你可以使用這個
DeviceLog.mr_truncateAll(in: context)
context.mr_saveToPersistentStoreAndWait()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.