Enforcing Editor vs. Viewer (was: Which way should my document class handle an older format?)
Enforcing Editor vs. Viewer (was: Which way should my document class handle an older format?)
- Subject: Enforcing Editor vs. Viewer (was: Which way should my document class handle an older format?)
- From: Daryle Walker <email@hidden>
- Date: Sun, 05 Mar 2017 20:08:31 -0500
> On Mar 4, 2017, at 3:40 AM, Daryle Walker <email@hidden> wrote:
>
> My document class reads in UTF-8 data for its internal format. The format has an older version that is ASCII-based. Since the latter is a subset of the former, my parser can handle both formats. Right now, I can’t write out in the older format. (The new format is just a text dump upon save. The old format would need to handle any post-ASCII values.)
>
> I’m wondering how I should be the old format in the Info.plist. I could put it in as a second document type. This lets me set it as “Viewer” independently of the first format being set to “Editor.” Altering the message and trying to save gives a system error about the file not being able to be saved. However, the “isInViewMode” flag doesn’t get set, so the document is editable! (But the edits can’t be saved.)
>
> The other way is to have one document type entry in the Info.plist, but put the old format as a second content type. Of course, it’ll always be in “Editor.” And the save sheet gets a pop-up menu for the format to be saved. I haven’t added an entry for exported-types in the p-list, so the menu is just the first type. The second type isn’t in the menu and if I try to duplicate the file (the new-world-order substitute for “Save As” since Lion), I get a can’t-be-saved error.
>
> I guess the second scenario seems to be what I want, but it still seems ugly. Are there any better solutions?
It seems like TextEdit does it the first way, and so does sample code in a relevant StackOverflow query, so I’m switching back.
But, does Apple's default code for NSDocument do anything differently between an “Editor” and a “Viewer”? (This can happen if a edit-type shares the same document subclass as a view-type.) Or do I have to check which mode myself and enforce editor-ness vs. viewer-ness myself?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden