On Mac OS X v10.7 and later:
- (void)setDisplayName:(NSString *)displayNameOrNil
v10.6, override in the NSDocument subclass:
- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel { if( [savePanel.nameFieldStringValue isEqualToString:@"Untitled"] ) [savePanel setNameFieldStringValue:@"hello"]; return [super prepareSavePanel:savePanel]; }
In fact, the default implementation is empty and returns YES, so it can just do it.
Iโm not sure that testing for โUntitledโ will not work if they have already been saved as โUntitledโ and want to keep this name, and maybe it will not be localized, so maybe set the flag to
- (id)initWithType:(NSString *)type error:(NSError **)error
or is there already one?
source share