Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSSet: add missing convenience initializer #2883

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Foundation/NSSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ open class NSSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCodi
self.init(array: [object])
}

public convenience init(objects elements: Any...) {
self.init(array: elements)
}

internal class func _objects(from aDecoder: NSCoder, allowDecodingNonindexedArrayKey: Bool = true) -> [NSObject] {
guard aDecoder.allowsKeyedCoding else {
preconditionFailure("Unkeyed coding is unsupported.")
Expand Down
4 changes: 4 additions & 0 deletions Tests/Foundation/Tests/TestNSSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class TestNSSet : XCTestCase {
XCTAssertEqual(set5, set3)
set5.add(2)
XCTAssertNotEqual(set5, set3)

let set6 = NSSet(objects: "foo", "bar")
XCTAssertEqual(set6.count, 2)
XCTAssertEqual(set2, set6)
}

func testInitWithSet() {
Expand Down