Arko Arko - 4 years ago 192
Swift Question

How to write this Objective-C delegate function in swift of NimbusKit Attributed Label

So I have this delegate function that is written in Objective-C but I'm bridging the class over to swift and can't figure out how to declare it in Swift.

- (void)attributedLabel:(NIAttributedLabel *)attributedLabel
didSelectTextCheckingResult:(NSTextCheckingResult *)result atPoint:(CGPoint)point;

This is the current function that I'm trying to use unsuccessfully:

func didSelectTextCheckingResult(result:NSTextCheckingResult, atPoint point:CGPoint) {
//[[UIApplication sharedApplication] openURL:result.URL];

Answer Source

If Objective-C expects this method:

- (void)attributedLabel:(NIAttributedLabel *)attributedLabel 
    didSelectTextCheckingResult:(NSTextCheckingResult *) result   

...then surely the Swift equivalent would be:

func attributedLabel(attributedLabel: NIAttributedLabel,
    didSelectTextCheckingResult result: NSTextCheckingResult,
    atPoint point: CGPoint) {
        // ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download