Circle
Circle

Reputation: 165

Cocoa renaming MyDocument window title

How can I change the title of a window in a document based cocoa application? I get an error when I try the following code in MyDocument.m

- (void)awakeFromNib
{
    [self setTitle:@"Document 1"];
}

Upvotes: 0

Views: 358

Answers (1)

Alex
Alex

Reputation: 26859

Override displayName and return the value you want displayed.

- (NSString *)displayName {
    return @"Document 1";
}

If you're subclassing NSWindowController then override windowTitleForDocumentDisplayName: instead.

Upvotes: 2

Related Questions