1

When I present a NSOpenPanel to the user I'd like it to have a file that the user opened earlier already selected from the start.

There is [NSSavePanel setDirectoryURL:(NSURL*) to preselect a directory, but I can't find an API to select the initial file.

There use to be:

- (NSInteger)runModalForDirectory:(NSString *)path file:(NSString *)filename

This call is exactly what I need. The docs say:

Specifies a particular file in path that is selected when the Save panel is presented to a user. When nil, no file is initially selected.

But unfortunately that method was deprecated in 10.6.

4

1 回答 1

1

做这些 NSSavePanel 方法

- (void)setDirectoryURL:(NSURL *)url
- (void)setNameFieldStringValue:(NSString *)value

不做你想做的事?

NSOpenPanel 是 NSSavePanel 的子类,所以它也有这些方法。

于 2011-11-26T13:00:29.227 回答