Ambiguous use of 'objects(passingTest:)'

After switching to swift 3 (GM Seed) the following code is giving me trouble:


let numbers = NSSet(array: [1, 2, 3, 4, 5, 6, 7, 8])
numbers.objects(passingTest: { (obj: Any, stop: UnsafeMutablePointer<ObjCBool>) -> Bool in
    return true
})


The error is: (at line 2) ambiguous use of objects(passingTest:).

Even though the other related API clearly takes an options parameter.

Accepted Reply

ahltorp has the right idea (use

Set
instead of NSSet) here but just FYI…

Even though the other related API clearly takes an

options
parameter.

Right, but that options parameter has a default value of

[]
so it could potentially be skipped.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

If you don't specifically need the "stop" functionality, you are probably better off using Set and filter instead.

Thanks, filter seems to work fine.

ahltorp has the right idea (use

Set
instead of NSSet) here but just FYI…

Even though the other related API clearly takes an

options
parameter.

Right, but that options parameter has a default value of

[]
so it could potentially be skipped.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"