这就是我所拥有的:
如何使标签包含桌面的当前路径,以及如何使其在他们点击选择时,他们可以选择安装位置,然后将标签设置为包含该路径?谢谢!
-(IBAction) choose : (id)sender;
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
if ([panel respondsToSelector:@selector(beginWithCompletionHandler:)]) {
//Mac OS X 10.6 and later
[panel beginWithCompletionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) { // Only if not cancelled
NSArray *urls = [panel URLs];
[text setStringValue:[[urls objectAtIndex:0]path]];
[panel orderOut:nil];
}
}];
}
else{
NSInteger result = [panel runModal];
if (result == NSFileHandlingPanelOKButton) {
NSArray *urls = [panel URLs];
[text setStringValue:[[urls objectAtIndex:0]path]];
[panel orderOut:nil];
}
}
}
- (void) awakeFromNib
{
NSString *docsDir = [NSHomeDirectory() stringByAppendingPathComponent: @"Desktop"];
[text setStringvalue: docsDir];
}