枚举字符串中的匹配项

enumerate matches in string

我正在重写我的字符串 class 确实简化了正则表达式的执行。在我升级到 Xcode 7 beta 和 swift 2.0 之前它运行良好。

regex.enumerateMatchesInString(str, options: NSMatchingOptions(rawValue: 0), range: all) {
        (result : NSTextCheckingResult!, _, _) in

// do stuff
}

我一直收到错误 "Cannot invoke 'enumerateMatchesInString' with an argument list of type '(String, options: NSMatchingOptions, range: _NSRange, (NSTextCheckingResult!, _, _) -> _)'"

我可以在不添加 closure/block 的情况下使它工作,但这违背了在字符串中使用枚举匹配的目的。

如果将 NSTextCheckingResult! 更改为 NSTextCheckingResult? 可能会起作用,因为这是实际的声明。