I have a core data class with this var:
@NSManaged var tags: NSSet?
The issue is that when the class is fetched from the data store, the tags variable instead of being nil, is initialised with an empty NSSet object.
Does this behaviour normal?
I thought it will be nil.
Update and question: I checked with the behaviour of a core data Attribute, and it is nil after the fetch.
Is it possible that for Relationships, which is NSSet/NSOrderedSet, core data doesn't use nil, but initialised an empty set?
Core Data uses faulting:
Essentially what happens here is:
A managed object fault is an instance of the appropriate class, but its persistent variables are not yet initialized.
A relationship fault is a subclass of the collection class that represents the relationship.
So you might have an instance of a set but you won't know what the persisten value is until you accessed it.
Hope this helps