On Mon, Sep 8, 2008 at 7:47 AM, Randy Widell <[EMAIL PROTECTED]> wrote: > If I am reading that right, it assumes that there is at least one window > already open (an empty document created when the app starts). The user > cannot create new documents; they can only edit existing documents. So, > initially at least, there will not be any windows to which the options and > password sheets can attach.
The code makes no assumptions about starting off with an empty document. The only assumption it makes is that every document will have at least one window associated with it, and that window is the one you want to display the sheet. All of this stuff happens in response to a document being opened or an untitled document being created. > I was also thinking it would be a little more intuitive if the sheets were > attached to the document window to which they apply. That is one reason why > I was thinking of deferring the work of reading the whole document until > after windowControllerDidLoadNib:. At that point, I would be able to attach > the sheets to the document's own window. Also, I didn't know you could > query the document controller for a window. That's good to know. Unless I made a glaring error in the code, that's what it's supposed to be doing. The document controller gets asked to open an untitled document (-openUntitledDocumentAndDisplay:) or to open an existing document (-openDocumentWithContentsOfURL:display:error:). Since you don't care about the first case, forget it exists. The MyDocumentController implementation of -openDocumentWithContentsOfURL:display:error: invokes the super implementation (which creates the MyDocument instance, adds it to the document controller's collection, and displays it), and then it tells the document to display its config sheet. The document obliges by starting a sheet attached to its first window ([self.windowControllers objectAtIndex:0].window). Hope that clarifies things a bit for you. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
