Search code examples
iosobjective-cswiftnsset

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.


Solution

  • 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").