I'm trying to create a sprite of a random monster where my images are stored in a folder referenced within the main bundle.
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
NSString* resourceFolderPath = [NSString stringWithFormat:@"%@/monsters", bundlePath];
NSArray* resourceFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:resourceFolderPath error:nil];
NSInteger randomFileIndex = arc4random() % [resourceFiles count];
NSString* randomFile = [resourceFiles objectAtIndex:randomFileIndex];
SKSpriteNode* tile = [SKSpriteNode spriteNodeWithImageNamed:randomFile];
When I run my code above, I get this error
SKTexture: Error loading image resource: "random_monster.png"
The code works if I reference the image from the main bundle. How can I use a random image from a folder within the app bundle and pass it to SKSpriteNode?