I struggle for weeks with this Bug and hope someone can give me a hint.
I use a CoreDate relationship (One to Many) and CoreData generates a NSSet? for me:
@NSManaged public var builds: NSSet?
Now I try to convert this NSSet to an Array and sometimes get a
malloc: double free for ptr 0x7fd48a008e00
malloc: *** set a breakpoint in malloc_error_break to debug
malloc: double free for ptr 0x7fd48a008e00
public var buildsArray: [CBuild] {
> let buildsArray = builds.array(ofType: CBuild.self)
return buildsArray.sorted {
$0.number > $1.number
}
}
extension Optional where Wrapped == NSSet {
func array<T: Hashable>(ofType: T.Type) -> [T] {
self?.allObjects as? [T] ?? [T]()
}
}
I use only background threads to write in CoreData but SwiftUI is executing this lines on main Thread. I don't know if this is the problem?