Cocoa Mac app title says "untitled"

I created a Mac OSX application based on a document, and when I edit in Interface Builder, the title is correct (I filled in that part of the inspector), but as soon as the program starts, the title of the application is "Untitled", How can I change it? In my IB Doc window, I have instances of File Owner, First Responder, NSApplication and NSWindow. No view controller, is this a problem? I am new to Cocoa ..

+6
objective-c xcode cocoa interface-builder macos
source share
5 answers

One solution is to override -displayName in your NSDocument subclass:

 - (NSString *)displayName { if (![self fileURL]) return @"Some custom untitled string"; return [super displayName]; } 

You can also check NSWindowController -windowTitleForDocumentDisplayName: if using custom window controllers.

+12
source share

You have created an application based on a Cocoa document. For new documents, Cocoa sets the proposed document name to "Untitled."

+2
source share

Do you mean the name of the application menu? This changes to match the name of the application at runtime. The easiest way to change this is to change the build setting of the Product Name on your target in Xcode.

+1
source share
 - (NSString *)displayName { NSMutableString *displayName = [NSMutableString stringWithString:[super displayName]]; if ([self fileURL] == nil) { NSString *firstCharacter = [[displayName substringToIndex:1] lowercaseString]; [displayName deleteCharactersInRange:NSMakeRange(0, 1)]; [displayName insertString:firstCharacter atIndex:0]; } return [NSString stringWithString:displayName]; } 
0
source share

This is because when creating this project you selected Create application document :

new project parameters

You can remove it from info.plist by clicking the button - next to Document Types :

info.plist

Enter your own title in the Storyboard and check the box on the "Invital Controller". After restarting the project, everything will be in order.

0
source share

All Articles