我会尽力完成翻译工作。以下是您需要翻译的内容:
我正在尝试获取资源文件夹子目录中所有png文件的数组。 在我的应用程序资源文件夹中,我创建了一个名为“images”的文件夹。此文件夹包含我需要显示的所有png文件。
这是我尝试获取路径的方法:
NSString *imagepath = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"images/"];
NSLog(@"Path to Images: %@", imagepath);
NSArray * paths = [NSBundle pathsForResourcesOfType: @"png" inDirectory:imagepath];
NSMutableArray * allImageNames = [[NSMutableArray alloc] init];
for ( NSString * path in paths )
{
if ( [[path lastPathComponent] hasPrefix: @"AQ"] )
continue;
[allImageNames addObject: [path lastPathComponent]];
}
我这样可以得到一个路径,例如…/appname.app/images
但如果我尝试这样做,那么数组总是为空的。 我错在哪里了?
问候, Zarak
image.AQ
这样吗? - Nekto[[path lastPathComponent] hasPrefix: @"AQ"]
? - Nekto