Document based app gives File->New-> ERROR only sometimes

I have a basic document based application. When I launch it and use the menu to make a new file it opens an untitled document window about 80% of the time. The other 20% it gives me this error:

2014-10-06 14:22:50.648 Stratimator-5[8564:303] *** -[CustomDocument windowNibName]: unrecognized selector sent to object <CustomDocument @0x6000000eeb80: OSAID(59) ComponentInstance(0x810000)>
(There’s a whole lot more to the error but I didn’t want to fill the page with it)

If I type ⌘N, which I always figured was identical to using the menu, it opens an untitled document window about 20% of the time, the error about 80% of the time.

There is no apparent pattern to the behavior.

So 2 questions -

What would cause this error to occur so randomly? What’s the difference between ⌘N right now and ⌘N 2 seconds from now except the time of day?

Why would it occur more often with ⌘N than with the menu equivalent?

Thanks,
Greg

Do you have a windowNibName() handler in your custom document class?

Yes, it is the default:


on windowNibName()
	return "CustomDocument"
end windowNibName

I created this before I got the latest version of The Book so I didn’t know I should put a prefix on the class, but I figured that was only important when using older versions of XCode-?
I stripped everything out of it to the bare bones and and deleted all my interface items and it still happens.
I think I need to start over again.

As long as your script has the same name, that’s fine – you don’t have to use a prefix.

Perhaps you can post a bit more of the doc’s code.