I'm attempting to do a write transaction for an array of data that I get from a remote server. While this works most of the time, it's been known to fail sporadically with an unexplained error ( see the crash logs for details). Here's the code of what I'm doing:
var contacts = [Contact]()
do {
let realm = try Current.realm()
realm.beginWrite()
for contactData in contactsData {
let contact = insertContact(contactData, realm: realm)
contacts.append(contact)
}
try realm.commitWrite()
} catch {
...
}
func insertContact(
_ contactData: [String: AnyObject],
realm: Realm? = nil
) -> Contact {
do {
let realm = try realm ?? Current.realm()
var contact: Contact
let storeContact = {
contact = realm.create(SWTContact.self, value: contactData, update: .all)
}
if realm.isInWriteTransaction {
storeContact()
} else {
realm.beginWrite()
storeContact()
try realm.commitWrite()
}
return contact
} catch {
...
}
...
}
How frequently does the bug occur?
Sometimes
Description
I'm attempting to do a write transaction for an array of data that I get from a remote server. While this works most of the time, it's been known to fail sporadically with an unexplained error ( see the crash logs for details). Here's the code of what I'm doing:
Stacktrace & log output
Can you reproduce the bug?
No
Reproduction Steps
No response
Version
10.28.2, 10.32.2
What Atlas Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
iOS 16, iOS 15, iOS 14, iPadOS 16
Build environment
Xcode version: ... Dependency manager and version: ...