Skip to content

Instantly share code, notes, and snippets.

@mikeabdullah
Created August 31, 2012 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeabdullah/3553124 to your computer and use it in GitHub Desktop.
Save mikeabdullah/3553124 to your computer and use it in GitHub Desktop.
Carefully suggesting a previous location to a save panel
NSSavePanel *savePanel = [NSSavePanel savePanel];
NSURL *url = [self mostRecentlySavedToURL];
NSURL *parentDirectory = [url URLByDeletingLastPathComponent];
NSNumber *isDirectory;
if ([parentDirectory getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL] &&
[isDirectory boolValue])
{
[savePanel setDirectoryURL:parentDirectory];
}
[savePanel setNameFieldStringValue:[url lastPathComponent]];
// Finish configuring and run the save panel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment