【发布时间】:2010-08-03 19:45:10
【问题描述】:
我正在尝试创建一个包含已拖入项目的文件夹内容的 NSStrings 数组...但是当我之后计算数组中的项目时,它总是返回 0;
所以,我的项目中的文件夹是这样的
-Cards
-Colors
Blue.png
Green.png
Orange.png
Yellow.png
Purple.png
Black.png
而我试图获取此文件列表(颜色 png)的代码是
NSError *error = nil;
NSString *pathString = [[NSString alloc] init];
pathString = [[NSString alloc] initWithString:@"/Cards/Colors/"];
NSArray *fileList = [[NSArray alloc] init];
fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathString error: &error];
[pathString release];
NSLog(@"%@", error);
// this is always 0
NSLog(@"file list has %i items", [fileList count]);
我得到的 NSError 是
Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x596db00 {NSUserStringVariant=(
Folder
), NSFilePath=/Cards/Color/, NSUnderlyingError=0x5925ef0 "The operation couldn’t be completed. No such file or directory"}
任何想法我哪里出错了?
【问题讨论】:
标签: iphone objective-c nsfilemanager