如何在Swift 3.0上区分相同的方法选择器?

时间:2016-09-18 06:18:59

标签: ios selector swift3

我在{10}或更新版本中找到UITextViewDelegate中的两种方法。

我好像他们有第二个参数的不同类型(URL或NSTextAttachment)。

optional func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool

optional func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool

当我使用选择器时:

#selector(self.textView(_:shouldInteractWith:in:interaction:)

这两种方法具有相同的语法来定义选择器,那么,如何区分它们以及如何修复错误Ambiguous use of 'textView(_:shouldInteractWith:in:interaction:)'

感谢您的帮助!

0 个答案:

没有答案