DisplayName not shown

  • I have a Document based app, which successfully uses setDisplayName: .

    But when the app restarts, it does:

    - (void)restoreStateWithCoder:(NSCoder *)coder
    {
    [ super restoreStateWithCoder: coder ];
    NSString *s = [ coder decodeObjectForKey: @"DisplayName" ];
    [ self setDisplayName: s ];
    }

    Now this display name is never seen. The window just shows "Untitled".

    It seems that setDisplayName: only works when the document does not yet have a window.
    But restoreStateWithCoder: is called after windowControllerDidLoadNib:.

    What is do be done?

    Kind regards,

    Gerriet.

    10.7.4
  • On May 25, 2012, at 23:26 , Gerriet M. Denkmann wrote:

    > But when the app restarts, it does:
    >
    > - (void)restoreStateWithCoder:(NSCoder *)coder
    > {
    > [ super restoreStateWithCoder: coder ];
    > NSString *s = [ coder decodeObjectForKey: @"DisplayName" ];
    > [ self setDisplayName: s ];
    > }
    >
    > Now this display name is never seen. The window just shows "Untitled".
    >
    > It seems that setDisplayName: only works when the document does not yet have a window.
    > But restoreStateWithCoder: is called after windowControllerDidLoadNib:.
    >
    > What is do be done?

    One answer, I guess, is simply to call 'setTitle:' on the window, if it already exists.
  • On 26 May 2012, at 23:03, Quincey Morris wrote:

    > On May 25, 2012, at 23:26 , Gerriet M. Denkmann wrote:
    >
    >> But when the app restarts, it does:
    >>
    >> - (void)restoreStateWithCoder:(NSCoder *)coder
    >> {
    >> [ super restoreStateWithCoder: coder ];
    >> NSString *s = [ coder decodeObjectForKey: @"DisplayName" ];
    >> [ self setDisplayName: s ];
    >> }
    >>
    >> Now this display name is never seen. The window just shows "Untitled".
    >>
    >> It seems that setDisplayName: only works when the document does not yet have a window.
    >> But restoreStateWithCoder: is called after windowControllerDidLoadNib:.
    >>
    >> What is do be done?
    >
    > One answer, I guess, is simply to call 'setTitle:' on the window, if it already exists.

    Yes. Did that. Works great.

    I was reluctant to do so, because I thought that the window title was somehow managed by the DocumentController and that setting it directly would mess things up.

    But so far I have not seen any adverse side-effects.

    Thanks for the tip.

    Gerriet.
previous month may 2012 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