Avoid creating a new document when launching an application

  • I have a Document-based application (NSPersisentDocument to be precise) for
    which I would like to override the default behavior when launching: I'd like to
    avoid creating a new blank document (for example by displaying an open dialog).

    How can I do this? What should I override? (Of course, the file:"new" command
    should still work)

    Bruno
  • On Oct 15, 2005, at 4:45 PM, <lists...> wrote:

    > I have a Document-based application (NSPersisentDocument to be
    > precise) for
    > which I would like to override the default behavior when launching:
    > I'd like to
    > avoid creating a new blank document (for example by displaying an
    > open dialog).
    >
    > How can I do this? What should I override? (Of course, the
    > file:"new" command
    > should still work)

    In your application delegate, implement -
    applicationShouldOpenUntitledFile:

    sherm--

    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
  • On Oct 15, 2005, at 1:45 PM, <lists...> wrote:

    > I have a Document-based application (NSPersisentDocument to be
    > precise) for
    > which I would like to override the default behavior when launching:
    > I'd like to
    > avoid creating a new blank document (for example by displaying an
    > open dialog).
    >

    Add this method to your app's delegate.

    - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
    {
        [[NSDocumentController sharedDocumentController]
    performSelector:@selector(openDocument:) withObject:self afterDelay:
    0.1];
        return NO;
    }

    _murat
previous month october 2005 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today
MindNode
MindNode offered a free license !