I solved a similar problem: I need to generate permanent Object IDs, which require the presence of a persistent store. Like you point out, untitled documents that haven't yet been autosaved don't have persistent stores.
This abbreviated snippet is from my NSWindowController subclass:
- (void) awakeFromNib {
//hacky way to get an autosave to generate an NSPersistentStore.
GSNativeDocument *doc = self.document;
[doc updateChangeCount:NSChangeDone];
[doc autosaveDocumentWithDelegate:self didAutosaveSelector:@selector(document:didAutosave:contextInfo:) contextInfo:nil];
}
//called by the autosave operation started in awakeFromNib.
- (void)document:(NSDocument *)document didAutosave:(BOOL)didAutosaveSuccessfully contextInfo:(void *)contextInfo
{
GSNativeDocument *doc = self.document;
[doc updateChangeCount:NSChangeUndone];
}
Why does updating the change count create a "real" autosave, when every other way to induce an autosave doesn't? I have no clue. I've filed this bug with Apple in early January and posted in the dev forums, but they have not answered.