I'm getting the error:
Could not find an overload for 'init' that accepts the supplied arguments
when I type:
var expr = NSRegularExpression(pattern: "test", options: 0, error: nil)
The error goes away if I pass a NSRegularExpressionOptions
member...
In Swift 2 nil
is not accepted, and the error is no longer an output parameter (it is thrown), so it becomes:
var expr = try NSRegularExpression(pattern: "test", options: [])
Use nil instead of 0. NSRegularExpressionOptions is a struct so you cannot pass an integer in for that parameter. In Objective-C the regular expression options were done with enums which evaluated to ints.
var expr = NSRegularExpression(pattern: "test", options: nil, error: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With