简体   繁体   English

获取Safari样式的文件路径

[英]Getting Safari-Style File Path

If you open Safari's Preferences and navigate to General, it has a drop-down menu next to the label 'Save downloaded files to.' 如果您打开Safari的“偏好设置”并导航至“常规”,则在“将下载的文件保存到”标签旁边会显示一个下拉菜单。 How do you get this Safari-style volume name or whatever? 您如何获得Safari样式的卷名或其他名称? I've done something like the following. 我已经做了以下类似的事情。 (I need to get it from a file path.) I don't get the same. (我需要从文件路径获取它。)我没有得到相同的结果。

- (NSString *)getVolumepath: (NSString *)path {
    NSArray *urlarray = [path componentsSeparatedByString:@"/"];
    NSString *p = [urlarray objectAtIndex:2];
    return  p;
}

Apple, Inc. says that you cannot show the full path to a sandbox-protected folder that is assigned to the application. Apple,Inc.说您无法显示分配给该应用程序的受沙盒保护的文件夹的完整路径。 But I want to show something like what Safari shows. 但我想显示类似Safari显示的内容。

Thank you for your advice. 感谢您的意见。

Following CodaFi's suggestion, it turns out to be as simple as the following. 遵循CodaFi的建议,事实证明它很简单。

- (NSString *)getlastpath: (NSString *)path {
    return  [path lastPathComponent];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM