I have an app that can save JSON data to a file, using
Right now, that file's type when viewed in the finder is a TextEdit type. Not sure why, maybe that's a default. I'd like to be able to set the file's type as something other than TextEdit. Ideally create my own file type, but at least mark it as JSON data. How can I do this? I tried fiddling around with .appendingPathExtension but this does not seem like a road that leads to what I'm after. I'd love to just to be able to subclass enough of NSDocument to do this... but I can't figure out how. NSDocument class hides so much of its code I can't figure out how it works. Actually what I'd really like is to see how NSDocument saves the file as a particular type... if I could find that code and use it while saving my data file, that'd be the best scenario.
Code Block try jsonData.write(to: fileURL, options: .atomic)
Right now, that file's type when viewed in the finder is a TextEdit type. Not sure why, maybe that's a default. I'd like to be able to set the file's type as something other than TextEdit. Ideally create my own file type, but at least mark it as JSON data. How can I do this? I tried fiddling around with .appendingPathExtension but this does not seem like a road that leads to what I'm after. I'd love to just to be able to subclass enough of NSDocument to do this... but I can't figure out how. NSDocument class hides so much of its code I can't figure out how it works. Actually what I'd really like is to see how NSDocument saves the file as a particular type... if I could find that code and use it while saving my data file, that'd be the best scenario.