【问题标题】:Get full path to a NSPathControl selected file获取 NSPathControl 选定文件的完整路径
【发布时间】:2010-11-05 22:03:56
【问题描述】:

我的应用中有一个 NSPathControl 供用户选择其硬盘上的文件。

我正在尝试使用

-(IBAction) clickedPath:(id) sender {

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

NSLog (@"%@", string);

}

但这只会输出文件名。如何获取文件的完整路径?

提前致谢!

【问题讨论】:

    标签: objective-c nspathcontrol


    【解决方案1】:

    尝试使用 URL 属性:

    - NSString *string=[[pathControl URL] path];
    

    【讨论】:

    • 谢谢!这就是我一直在寻找的
    猜你喜欢
    • 2021-12-08
    • 2015-09-13
    • 2015-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2012-10-19
    • 2018-10-24
    相关资源
    最近更新 更多