0
我想从我的应用程序的文档文件夹中的文件名称构造一个字符串。NSMutableString返回null
到目前为止,我有:
NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [directoryPaths objectAtIndex:0];
NSError *error = nil;
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:&error];
NSLog(@"contents of document folder = %@", directoryContent);
此打印:
contents of app's document folder = (
".DS_Store",
File1.doc,
"File2.pdf",
....
)
我想构建文件名的字符串,以某种方式分开,或许是分号,并企图它(最初没有任何分离)通过此代码:
NSMutableString *fileList;
for (NSString *folder in directoryContent)
{
[fileList appendString:[NSString stringWithFormat:@"%@", folder]];
}
NSLog(@"file list = %@", fileList);
这打印file list = (null)
和I无法弄清楚我要去哪里错了。有任何想法吗?
D'oh!非常感谢你。这确实是个问题。多谢。 – Robert