Reputation: 3271
When i implement the func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool
OR func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
method in my swift class, it gives error and warning as shown below.
error : Use of undeclared type 'URL'
warning : Instance method 'textView(_:shouldInteractWith:in:)' nearly matches optional requirement 'textView(_:shouldInteractWith:in:)' of protocol 'UITextViewDelegate'
If I Change the class name to NSURL
instead of URL
, it compiles properly but warning never goes off.
Also the above methods are not called while interacting with URL in my textView
Thanks!
Upvotes: 1
Views: 1118
Reputation: 47906
Try changing the method header to something like this:
func textView(_ textView: UITextView, shouldInteractWith url: URL, in characterRange: NSRange) -> Bool
(The formal parameter url
needs to be in lower case.)
This definitely is a bug of Swift/Xcode. The formal parameter URL
is shadowing the type URL
.
Upvotes: 2