Unfortunately, I do not know why this is not working properly. I would suggest that Swift Setalso has a function member- apparently it is not .
The module documentation Swiftsays:
/// A shadow for the "core operations" of NSSet.
///
/// Covers a set of operations everyone needs to implement in order to
/// be a useful `NSSet` subclass.
@objc public protocol _NSSetCoreType : _NSCopyingType, _NSFastEnumerationType {
public init(objects: UnsafePointer<AnyObject?>, count: Int)
public var count: Int { get }
public func member(object: AnyObject) -> AnyObject?
public func objectEnumerator() -> _NSEnumeratorType
public func copyWithZone(zone: _SwiftNSZone) -> AnyObject
public func countByEnumeratingWithState(state: UnsafeMutablePointer<_SwiftNSFastEnumerationState>, objects: UnsafeMutablePointer<AnyObject>, count: Int) -> Int
}
which sounds like all of these features are not available in Swift (I could be wrong about that, but it seems to be true).
- NSMutableSet ( , Objective-C):
var itemsSet : NSMutableSet = NSMutableSet()
itemsSet.addObject("bla")
let existingItem = itemsSet.member("bla")
- , "Swift ":
let item = CustomItem(something: "")
if let index = itemsSet.indexOf(item) {
let existingItem = itemsSet[index]
existingItem.something = "somethingElse"
}