Skip to content

Commit cc44f12

Browse files
committed
Change NSMutableSet to align with Darwin version
1 parent 70d58cb commit cc44f12

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

Foundation/NSPredicate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ extension NSMutableSet {
112112
public func filterUsingPredicate(_ predicate: NSPredicate) {
113113
for object in self {
114114
if !predicate.evaluateWithObject(object) {
115-
self.removeObject(object)
115+
self.remove(object)
116116
}
117117
}
118118
} // evaluate a predicate against a set of objects and filter the mutable set directly

Foundation/NSSet.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ extension NSSet : Sequence {
354354

355355
public class NSMutableSet : NSSet {
356356

357-
public func addObject(_ object: AnyObject) {
357+
public func add(_ object: AnyObject) {
358358
if self.dynamicType === NSMutableSet.self {
359359
_storage.insert(object as! NSObject)
360360
} else {
361361
NSRequiresConcreteImplementation()
362362
}
363363
}
364364

365-
public func removeObject(_ object: AnyObject) {
365+
public func remove(_ object: AnyObject) {
366366
if self.dynamicType === NSMutableSet.self {
367367
if let obj = object as? NSObject {
368368
_storage.remove(obj)
@@ -384,17 +384,17 @@ public class NSMutableSet : NSSet {
384384
super.init(objects: [], count: 0)
385385
}
386386

387-
public required convenience init?(coder: NSCoder) {
387+
public required convenience init?(coder aDecoder: NSCoder) {
388388
NSUnimplemented()
389389
}
390390

391-
public func addObjectsFromArray(_ array: [AnyObject]) {
391+
public func addObjects(from array: [AnyObject]) {
392392
if self.dynamicType === NSMutableSet.self {
393393
for case let obj as NSObject in array {
394394
_storage.insert(obj)
395395
}
396396
} else {
397-
array.forEach(addObject)
397+
array.forEach(add)
398398
}
399399
}
400400

@@ -403,32 +403,32 @@ public class NSMutableSet : NSSet {
403403
_storage.formIntersection(otherSet)
404404
} else {
405405
for case let obj as NSObject in self where !otherSet.contains(obj) {
406-
removeObject(obj)
406+
remove(obj)
407407
}
408408
}
409409
}
410410

411-
public func minusSet(_ otherSet: Set<NSObject>) {
411+
public func minus(_ otherSet: Set<NSObject>) {
412412
if self.dynamicType === NSMutableSet.self {
413413
_storage.subtract(otherSet)
414414
} else {
415-
otherSet.forEach(removeObject)
415+
otherSet.forEach(remove)
416416
}
417417
}
418418

419419
public func removeAllObjects() {
420420
if self.dynamicType === NSMutableSet.self {
421421
_storage.removeAll()
422422
} else {
423-
forEach(removeObject)
423+
forEach(remove)
424424
}
425425
}
426426

427-
public func unionSet(_ otherSet: Set<NSObject>) {
427+
public func union(_ otherSet: Set<NSObject>) {
428428
if self.dynamicType === NSMutableSet.self {
429429
_storage.formUnion(otherSet)
430430
} else {
431-
otherSet.forEach(addObject)
431+
otherSet.forEach(add)
432432
}
433433
}
434434

@@ -437,7 +437,7 @@ public class NSMutableSet : NSSet {
437437
_storage = otherSet
438438
} else {
439439
removeAllObjects()
440-
unionSet(otherSet)
440+
union(otherSet)
441441
}
442442
}
443443

@@ -507,7 +507,7 @@ public class NSCountedSet : NSMutableSet {
507507
}
508508
}
509509

510-
public override func addObject(_ object: AnyObject) {
510+
public override func add(_ object: AnyObject) {
511511
if self.dynamicType === NSCountedSet.self {
512512
if let count = _table[object as! NSObject] {
513513
_table[object as! NSObject] = count + 1
@@ -520,7 +520,7 @@ public class NSCountedSet : NSMutableSet {
520520
}
521521
}
522522

523-
public override func removeObject(_ object: AnyObject) {
523+
public override func remove(_ object: AnyObject) {
524524
if self.dynamicType === NSCountedSet.self {
525525
guard let count = _table[object as! NSObject] else {
526526
return
@@ -541,7 +541,7 @@ public class NSCountedSet : NSMutableSet {
541541
_storage.removeAll()
542542
_table.removeAll()
543543
} else {
544-
forEach(removeObject)
544+
forEach(remove)
545545
}
546546
}
547547
}

TestFoundation/TestNSFileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class TestNSFileManager : XCTestCase {
211211
if let e = NSFileManager.defaultManager().enumerator(atPath: basePath) {
212212
let foundItems = NSMutableSet()
213213
while let item = e.nextObject() as? NSString {
214-
foundItems.addObject(item)
214+
foundItems.add(item)
215215
}
216216
XCTAssertEqual(foundItems, NSMutableSet(array: ["item".bridge(),"path2".bridge(),"path2/item".bridge()]))
217217
} else {

TestFoundation/TestNSSet.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class TestNSSet : XCTestCase {
8484

8585
func test_setOperations() {
8686
let set = NSMutableSet(array: ["foo", "bar"].bridge().bridge())
87-
set.unionSet(["bar".bridge(), "baz".bridge()])
87+
set.union(["bar".bridge(), "baz".bridge()])
8888
XCTAssertTrue(set.isEqualToSet(["foo".bridge(), "bar".bridge(), "baz".bridge()]))
8989
}
9090

@@ -185,9 +185,9 @@ class TestNSSet : XCTestCase {
185185

186186
XCTAssertEqual(set.countForObject(v1), 2)
187187
XCTAssertEqual(set.countForObject(v2), 1)
188-
set.addObject(v3asv1)
188+
set.add(v3asv1)
189189
XCTAssertEqual(set.countForObject(v1), 3)
190-
set.addObjectsFromArray([v1,v2])
190+
set.addObjects(from: [v1,v2])
191191
XCTAssertEqual(set.countForObject(v1), 4)
192192
XCTAssertEqual(set.countForObject(v2), 2)
193193
}
@@ -200,10 +200,10 @@ class TestNSSet : XCTestCase {
200200

201201
XCTAssertEqual(set.countForObject(v1), 2)
202202
XCTAssertEqual(set.countForObject(v2), 1)
203-
set.removeObject(v2)
203+
set.remove(v2)
204204
XCTAssertEqual(set.countForObject(v2), 0)
205205
XCTAssertEqual(set.countForObject(v1), 2)
206-
set.removeObject(v2)
206+
set.remove(v2)
207207
XCTAssertEqual(set.countForObject(v2), 0)
208208
XCTAssertEqual(set.countForObject(v1), 2)
209209
set.removeAllObjects()
@@ -227,4 +227,4 @@ class TestNSSet : XCTestCase {
227227
}
228228
}
229229

230-
}
230+
}

0 commit comments

Comments
 (0)