Bartłomiej Semańczyk Bartłomiej Semańczyk - 4 years ago 87
Swift Question

NSSet setByAddingObject in Swift 1.2

What is equivalent of

setByAddingObject:
in Swift. I have an
NSSet
property from Objective-C in Swift. But since Apple released Xcode 6.3 I have an error in this place:

Example:

NSSet *set;

object.set = object.set.setByAddingObject("text/html")


It produces error:

'Set<NSObject>' does not have a member named 'setByAddingObject'


enter image description here

Any idea, how to fix this?
insert
method doesn't work also.

Answer Source

Swift 1.2 added its own Set type, which is bridged over to Swift from Objective-C in a similar fashion to NSArray/Array and NSString/String. Try object.set.insert("text/html").

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download