5
一个在应用程序的链接,我发现这个小片段,使人们在一个NSTextView创建文本链接:创建于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];
}
是否可以有链接指向一些资源在我的应用程序,例如,一个特定的处理程序类能够解释链接并分派到相应的视图/控制器?