我的应用程序中有一个nspathcontrol,供用户在硬盘上选择一个文件。

我正在尝试使用

-(IBAction) clickedPath:(id) sender {

NSString *string=[[NSString alloc] initWithFormat:[[pathControl clickedPathComponentCell] stringValue]];

NSLog (@"%@", string);

}

但这仅输出文件名。如何获得文件的完整路径?

提前致谢!

有帮助吗?

解决方案

尝试使用URL属性:

- NSString *string=[[pathControl URL] path];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top