Create hyperlink to some text in NSTextView

匆匆过客 提交于 2019-12-06 16:44:33

I haven't done this in a while so take this with a grain of salt but it goes something like:

  1. You need to define a protocol for you app to handle URLs. It will look something like "myApplicationName://aPath"
  2. In the apps Info.plistfile add the protocol under CFBundleURLTypes key.
  3. Write code for the app to respond to openURL from NSWorkspace. This means the app will have to understand how to convert a URL style path to a specific location in one of its documents.

I think the best method for handling the URL path is to assign a UUID to each document and then a numeric scheme to the paragraph and sentences. The URL ends up looking like: myApplicationName://UUID/paragraphNumber/sentenceNumber/wordNumber. Alternatively you can insert hidden text to define an anchor and just search for that anchor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!