Document App: Triggering Behaviour After a New Document

Discussion in 'Mac Programming' started by knightlie, Apr 30, 2012.

  1. macrumors 6502a

    Feb 18, 2008
    I have a Core Data document-based application which is all working correctly. I'd like to implement a "New Document wizard" which appears as a sheet after the user has created a new document - the wizard will ask some questions and populate aspects of the document with the users choices. The wizard is displayed by a method of the document controller class.

    I've tried calling the method in a number of places but none of them seem to work. Placing the call in awakeFromNib or windowControllerDidLoadNib: causes an infinite loop.

    Does anyone have an idea of the best method to place this call in? I guess I'm looking for some kind of "document has finished being created" method to override, or notification to observe.

    Thanks in advance.
  2. macrumors 68030

    Oct 19, 2011
    Yes, that is what you need to overwrite. The method that is called only when a new Document is created (and not when an existing one is opened) is
    - initWithType:error:
    See the documentation.

    You should also have a look at the basic guide for document based applications, I found it quite useful.
  3. thread starter macrumors 6502a

    Feb 18, 2008

Share This Page