NSPathControl设置路径

时间:2013-01-10 11:52:32

标签: objective-c path nspathcontrol

我正在寻找一种方法将NSPathControl的路径设置为“〜/ Desktop”。

2 个答案:

答案 0 :(得分:4)

[_pathControlOutlet setURL: [NSURL URLWithString: [@"~/Desktop"stringByExpandingTildeInPath] ]];


NSURL *pathURL = [_pathControlOutlet URL];
NSLog(@"%@",[[_pathControlOutlet URL]path]);

NSString *pathSegmentClicked = [[_pathControlOutlet clickedPathComponentCell]title];

NSLog(@"%@",pathSegmentClicked);
NSLog(@"%@",pathURL);

答案 1 :(得分:2)

NSURL *pathURL = [NSURL fileURLWithPath:[@"~/Desktop stringByExpandingTildeInPath]];
[pathControl setURL:pathURL];