Implementing a weakly referencing set in Swift
By default all collection types in Swift, or Objective C for that matter, reference their objects (in case they are objects, not structs) in a strong manner so the objects won’t get deallocated unless the collection itself is deallocated. For most use cases this is just fine, since you don’t want objects to disappear out of the blue after they are added to the collection. However, for some use cases a strong reference may not be what you want.