How to implement the “New Document” window like Pages app does?

Discussion in 'Mac Programming' started by voidmain, Jul 5, 2014.

  1. voidmain macrumors newbie

    Mar 18, 2014
    Being a OS X user, you must be quite familiar with the "New Documents" window when you start some of these star apps: Pages, Pixelmator, Sketch and so on.


    I'm building a document-based app, and I want to popup this window when user launches my app. This window is so common, that I 99% sure it is a system-provided window. But I couldn't find it.

    I can mimic the window, but this process must be really tedious and buggy. For example, I have to manage the list-style switch using NSBrowser, NSSourceList and NSTableList, also, there are bunch of code managing drag and drop, search, iCloud integration... The list must be pretty long, and I felt this wheel is really not needed to be reinvented...

    So, my question is how can I implement this window, is there any documentation writing about this window? Big thanks!
  2. Blakeasd macrumors 6502a

    Dec 29, 2009
    You need to add iCloud entitlements to your project.
  3. voidmain thread starter macrumors newbie

    Mar 18, 2014
    This windows has some minor differences with NSOpenPanel

    Thanks guys for your reply, and I've added iCloud support in my app:


    Also, I've fired the NSOpenPanel with the following code:

    NSOpenPanel *panel = [NSOpenPanel openPanel];
        [panel beginWithCompletionHandler:^(NSInteger result){
            if (result == NSFileHandlingPanelOKButton) {
                NSURL*  theDoc = [[panel URLs] objectAtIndex:0];
                // Open  the document.
                NSLog(@"What: %@", theDoc);
    But the panel has some minor differences with the window I'm looking for. Here's the NSOpenPanel:


    You can notice that there's no iCloud tab, and to me, the panel does have a `New Document` button... Am I wrong with iCloud setup?
  4. voidmain thread starter macrumors newbie

    Mar 18, 2014
    Got that window..

    It turns out all you need to do to get this window is enable iCloud support..

    What took me so long is the window doesn't show up with Swift/Xcode6-Beta, I don't know why... I've started a fresh new project in Xcode5 with ObjC, and enabling iCloud in `Capabilities` page does give me this window..

    Thanks guys for your help!
  5. 960design macrumors 68030

    Apr 17, 2012
    Destin, FL
    Thanks for taking the time to come back and let us know what happened. You probably saved me several frustrating hours, hopefully it will help more and/or get fixed before I need it for real.
  6. voidmain thread starter macrumors newbie

    Mar 18, 2014
    I would be thrilled if my experience can help you guys. ;)

Share This Page