我正在尝试确定数组是否包含具有以下代码的目录:
for (NSString *item in folderContents)
{
NSString *itemPath = [subPath stringByAppendingPathComponent:item];
BOOL isDirectory;
if ([[NSFileManager defaultManager] fileExistsAtPath:subPath isDirectory:&isDirectory])
{
if (isDirectory)
{
NSLog(@"sub-directory: %@", itemPath);
}
else
{
NSLog(@"document path: %@", itemPath);
}
}
}
目前,该数组包含表示目录和.pdf文件的字符串,但两者都记录为目录:
sub-directory: /Users/.../Documents/downloads/Notices/folder/test document.pdf
sub-directory: /Users/.../Documents/downloads/Notices/folder/test folder
谁能告诉我我错过了什么?
答案 0 :(得分:1)
您仍然测试子路径,而不是项目路径