My app that I’m developing in AppKit, use two type of file:
custom type with extension webcodeproj: is based on public.data and it is the type of the app. it is the file that is created when you create a new project and contains all information about the project.
text type file: the app starting with the possibility to create, read, edit and delete file of type text with extension HTML and CSS
This sample app is a text editor, implementing a subclass of NSDocument called Document with a data model called Content.
The Content object encapsulates the document’s data into a single package. Putting all of the document’s data into a single Content object simplifies data management. For example, it’s easier to add new data elements to the document later.
The Content object contains a single attribute called contentString, which is made up of a single String.
This is perfect for only one type and because the sample app is a text editor, is perfect for me. but I’ve two question:
how can I handle also the custom type of files(in my case webcoreproj) that is not a text?
both html and css are text file, how can I eventually manage the files separately?
the methods
Hi @rufy . First, there is no need to page Sara or I on your messages, anybody in this Forum that can answer, will answer. Also, we all do this voluntarily, please be respectful of our time.
As for your question, the typeName actually refers to Uniform Type Identifier names. They look like this:
I’m sorry Roberto! I know that anybody in this Forum can answer. Anybody will answer? unfortunately I’m not so sure. And actually only you and Sarah has write the book “MacOS by Tutorials” and, for this reason, surely can answer to questions about MacOS. In fact the tutorials about macOS development are yours. I absolutely didn’t want to disrespect you or to Sarah regarding your time. and I did not expect such a prompt response. usually my questions after 6 months are closed without an answer or a really useful answer to solve the problem. and if this is true for swift / ios even more so for MacOS, where tutorials and updated documentation are really sparse. Unfortunately, the fact that the book only dealt with the subject for SwiftUI disappointed me a bit. that’s why I try to contact you as much as possible. I have this project that I would like to develop but, as I said, updated documentation and tutorials are very few. But I understand that you are busy. therefore, in the hope that you write articles for Appkit and receive sensible answers from users of this Forum, I will write the posts without putting your name.
Sorry
You’ll set up a file type just like you did for HTML & CSS files, but using your own unique identifier. then you can save and read the file as Data. After. that, how you process it depends on your internal file structure.
I would expect the typeName to be whatever identifier you used like “public.css” or “public.html” but its easy to test this by printing out the typeName.