【发布时间】:2012-06-29 10:28:16
【问题描述】:
我已完成以下步骤。 1.创建了一个xcode项目,并在Supporting Files里面创建了一个名为“Images”的文件夹。
-
将 4 张图片拖放到其中。尝试使用以下代码访问这些文件
NSString *pathString = [[NSBundle mainBundle] pathForResource:@"Images" ofType:nil]; NSArray *fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathString error: nil]; NSLog(@"the fileList is %d",[fileList count]);
计数始终为 0。我现在该怎么办?里面有文件,我可以在 imageviews 中使用它。
那么我犯了什么错误?
【问题讨论】:
-
任何东西,现在我只希望计数至少为 +1。
-
应用程序包不会为您在 xcode 中的任何资源创建任何文件夹/子文件夹。
-
好的,我知道。但是,我怎样才能区分不同文件夹中的某些文件。没有办法吗?
-
虽然我在下面的回答中已经解释过了,但你必须参考这个链接:mobiledevelopertips.com/xcode/…
标签: iphone filesystems xcode4.2 nsbundle