1
votes

I'm having a odd problem with an NSDocument-based application I am writing. When I first create a document and save it everything works as it should. However, when I reopen the document (which works just fine), neither "Save", "Save as" nor "Revert to saved" in the main menu seem to have any effect. The method

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError

never gets called. The main menu "Close" behavior is also strange: it closes the main document window, but none of the ancillary windows. Again, this irregular behavior is only observed when the document is opened; clicking on "Close" in the main menu works as expected when the document is newly created. Other menu items, both the "Open" item and my own custom items work fine.

This is an application that was developed in Snow Leopard and then Lion, and it didn't have any problems then. I've recently upgraded to Mountain Lion, but I am not sure if the problems began there or if I did something to the project to cause the behavior. The current SDK being used to compile the app is 10.7.

Any info would be much appreciated, and thanks in advance,

c.

2
Anything in the console?TheAmateurProgrammer
Nothing that I didn't put there. Digging a bit I've noticed that - (void)saveToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo is not getting called.trip
So it seems that when documents are loaded there is no NSWindowController in the _windowControllers array of my NSDocument subclass. I am not using the -makeWindowControllers method, and it was working fine without it before. Any thoughts as to why a document would be loaded but its NSWindowController not created?trip
@trip: You should add that info to your question. It sounds like that is your real problem here, so burying it in a comment isn't doing any favors.Chuck

2 Answers

0
votes

Well, if your application allows, you can use Core Data. That would certainly remove the bug and let you build your app only with bindings.

0
votes

Well, it seems that I fixed it, but I have no idea how. After debugging I realized that the WindowController was indeed getting instantiated, so it wasn't that. I ended up combining an old version of the project with some of the new code which initially displayed the same behavior, but at some point it didn't anymore. I wish I knew what I did to both break it and fix it, but I'm glad it works now!

And thanks Moray, I think it is time to move to Core Data.

Thanks all,

c.