I am quite new in iOS development and Objective-C and I would appreciate some help.
I created a Group folder
in Xcode where I placed all my images. All my images are inside the project folder.
I want to iterate through the Xcode folder routineIcons
and get all Images that have b-
in their name and put their name and extension into an array.
Could anyone point me in the right direction on how to do this? bah.. is it possible??
You can use this snipped:
NSMutableArray *result = [NSMutableArray array];
[[[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
NSString *path = [obj lastPathComponent];
if ([path hasPrefix:@"b-"]) {
[result addObject:path];
}
}];
At runtime, the routineIcons
folder won't exist. All of those images, along with all other resources, will end up in the app's resource bundle.
What you can do is get the path to the resource bundle then use NSFileManager
to get all of the files in the folder. You can then ignore any that don't start with "b-".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With