I found this little snippet which allows one to create links from text in an NSTextView:
-(void)setHyperlinkWithTextView:(NSTextView*)inTextView
{
// create the attributed string
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
// create the url and use it for our attributed string
NSURL* url = [NSURL URLWithString: @"http://www.apple.com"];
[string appendAttributedString:[NSAttributedString hyperlinkFromString:@"Apple Computer" withURL:url]];
// apply it to the NSTextView s text storage
[[inTextView textStorage] setAttributedString: string];
}
在我的申请中,能否把链接点与某些资源联系起来,例如与能够解释联系和向相应观点/控制者发送的具体手递类别联系起来?