gpt4 book ai didi

objective-c - 查找路径的父目录

转载 作者:太空狗 更新时间:2023-10-30 03:09:42 24 4
gpt4 key购买 nike

有没有办法使用 NSFileManager 或其他东西找到路径的父目录?

例如拿这个:

/path/to/something

然后把它变成

/path/to/

最佳答案

NSString 方法 -stringByDeletingLastPathComponent 就是这样做的。

你可以这样使用它:

NSLog(@"%@", [@"/tmp/afolder" stringByDeletingLastPathComponent]);

它会记录/tmp

关于objective-c - 查找路径的父目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1309524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com