Re: What exactly does NSDocumentController do when there's no NSDocument architecture?
Re: What exactly does NSDocumentController do when there's no NSDocument architecture?
- Subject: Re: What exactly does NSDocumentController do when there's no NSDocument architecture?
- From: Daryle Walker <email@hidden>
- Date: Wed, 27 Aug 2014 14:48:40 -0400
On Aug 27, 2014, at 6:36 AM, Manoah F. Adams <email@hidden> wrote:
> On Aug 27, 2014, at 02:03:000, Daryle Walker wrote:
>
>> AFAIK, NSDocumentController has the only API for the “Open Recent” menu[1], so I added it (back) to my project. I moved my app delegate’s actions for the New and Open menu commands to my NSDocumentController subclass, but they wouldn’t activate until I forced them with an override of the user-interface validation method. It now seems understandable; since the controller can’t find any NSDocument stuff, it shuts out any method that needs the architecture. The “Open Recent” menu API has a NSDocument-based and an URL-based entry API; the latter meant for non-NSDocument apps to use.
>>
>> But I saw something weird one time running my app through the Xcode debugger after a previous crash. I saw an NSLog message complaining about app restore data. I think NSDocumentController does app-restore actions even without an NSDocument architecture. Is this documented? What APIs can I use to control this? Are there other automatic actions NSDocumentController (or a subclass) does when initialized? (I just need it for the “Open Recent” menu, so I want to shut down, or at least check myself, any other automation.)
>>
>> [1] For writing new entries. If you started with NSDocumentController, then rip it out, the “Open Recent” menu stays, unchanging but functional. (I never tried the “Clear Menu” option during that period.)
>
>
> If the Open Recent menu is all you are after, maybe the problem is in the subclassing of NSDocumentController. Just leave that out.
> For me this one-liner has always worked:
> [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:filePath]];
> ... called whenever I create a new item or open an existing one.
I don’t override -init, so using a subclass shouldn’t make a difference; it’s the -init of NSDocumentController that is setting up extra things (unless there’s a -isMemberOfClass: check somewhere).
—
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