SwiftData relationships — are they really areas?

In CoreData, many-relationships are implemented as NSSet objects. In the SwiftData examples, they are shown as arrays. Are they really arrays (i.e., order-preserving and duplicates allowed) or are they arrays made from CoreData NSSets? In my applications, this makes a HUGE difference.

Replies

I've just discovered today that I'm seeing non-order-preserving behavior, despite using a "stored" array as the to-many model relationship property. Others are also discovering this issue. See here: Swift forums

I haven't investigated duplicate insertion behavior.

Order-preserving behavior is critical for my app as well. I haven't seen any indication in the SwiftData docs or API that this is intended behavior, so I'll be filing a bug report and looking for workarounds in the meantime. I hope you do as well!