Reputation: 4523
Given an NSSet what is the best way to get an NSMutableSet with those same objects?
To be clear if you have an instance of NSSet what would be the most performant and simple way to get an NSMutable set with those same objects?
Upvotes: -5
Views: 932
Reputation: 12154
There are 2 ways to achieve it.
Use mutableCopy
Objective-C
NSMutableSet* mutableSet2 = [YOUR_SET mutableCopy];
Swift
let mutableSet = YOUR_SET.mutableCopy()
Use setWithSet:
Objective-C
NSMutableSet* mutableSet = [NSMutableSet setWithSet:YOUR_SET];
Swift
let mutableSet = NSMutableSet.init(set: YOUR_SET)
Upvotes: 3