NSDocument-based app

Steven Vandeweghe's Avatar

Steven Vandeweghe

21 Jul, 2012 09:32 AM

What would be the best way to implement HockeySDK in an NSDocument-based Mac app? I've left the -showMainApplicationWindow method empty for now since my app delegate doesn't have a main window (windows are loaded by an NSWindowController subclass). Is that the recommended way to work?

Steven

  1. Support Staff 2 Posted by Andreas Linde on 23 Jul, 2012 03:26 PM

    Andreas Linde's Avatar

    Hello Steven,

    sorry for the late response. I needed to get some expert info on that, since I've never dealt with NSDocument based apps myself so far.

    The advice is as follows:
    - Do what you did :) - Setup the SDK at the end of applicationDidFInishLaunching, since otherwise you may loose the Apple events to restore, open untitled document etc.

    This way you will not be able to catch crashes coming up earlier, but the SDK won't make anything worse in that scenario. We have some ideas on how to make this better, but that needs some time for implementation and testing and we are currently busy with some other tasks. But the way described should work so far.

    Best,
    Andreas

  2. 3 Posted by Thomas on 09 Aug, 2012 12:06 AM

    Thomas's Avatar

    How would I open an untitled window on startup if needed?

    I tried:

    - (void)showMainApplicationWindow {
        [[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
    }
    

    but this also opens an untitled window when restoration happens. What is the recommended way to do this? It seems like applicationShouldOpenUntitledFile is not being called.

  3. Support Staff 4 Posted by Andreas Linde on 09 Aug, 2012 09:52 AM

    Andreas Linde's Avatar

    Hi Thomas,

    just don't do anything in that method and show your UI as always. Also make sure to initialize the SDK at the end of applicationDidFinishLaunching as mentioned in my previous post.

    Best,
    Andreas

  4. 5 Posted by Thomas on 12 Aug, 2012 04:16 AM

    Thomas's Avatar

    Hi Andreas,

    If I leave showMainApplicationWindow empty and initialize the framework in applicationDidFinishLaunching as you are suggesting, and I open the app, close all windows, quit the app and then relaunch the app then I don't get any windows when I reopen the app. I suppose this may be related to window restoration. What I want is to have one untitled window in this scenario.

    Please let me know if you've ran into this issue and how I could fix it.

    Thomas

  5. Support Staff 6 Posted by Andreas Linde on 13 Aug, 2012 09:23 PM

    Andreas Linde's Avatar

    Hi Thomas,

    my experience with document based Mac apps is sadly very very limited, so I don't know how to fix this.

    We have another approach on our todo list for the Mac SDK to show the crash report dialog when the crash report occurs and not on the next startup. But we need quite some time to implement and test it, since that is quite tricky to do, especially in the sandbox. And we are not sure yet if we can make it work. But that would solve your problem and some others too.

    Sorry I don't have a better answer for you,
    Andreas

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.