我正在尝试检查选择的特定项目是文件夹还是文件。我为isDir和isFile设置了标记。
一旦选择的项目是文件夹,我设置isDir = true但是如果选择的特定文件夹是桌面,我需要设置另一个标志。
目标C中的条件是什么。
答案 0 :(得分:0)
您可以取出字符串的最后一部分,并将其与桌面文件夹进行比较
NSString *lastPart = [filePath.absoluteString lastPathComponent];
或者,如果您的filePath已经是NSString而不是NSURL
NSString *lastPart = [filePath lastPathComponent];