如何在快速的NimbusKit归属标签中编写这个Objective-C委托函数

时间:2016-01-04 23:49:01

标签: ios objective-c swift delegates

所以我有这个用Objective-C编写的委托函数,但是我把这个类桥接到了swift,无法弄清楚如何在Swift中声明它。

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

这是我尝试使用失败的当前功能:

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

1 个答案:

答案 0 :(得分:1)

如果Objective-C需要这种方法:

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

......那么Swift的等价物肯定是:

func attributedLabel(attributedLabel: NIAttributedLabel,
    didSelectTextCheckingResult result: NSTextCheckingResult,
    atPoint point: CGPoint) {
        // ...
}