I have a folder of png's called "cards" in Supporting Files. I'm trying to set a pic as a UIImage instance variable for a object. When i try to NSLog the UIImage i get null.
I don't think I'm accessing the path to the pics correctly, but not sure ????
#import "Deck.h"
#import "Card.h"
@implementation Deck
@synthesize cards;
- (id) init
{
if(self = [super init])
{
cards = [[NSMutableArray alloc] init];
NSInteger aCount, picNum = 0;
for(int suit = 0; suit < 4; suit++)
{
for(int face = 1; face < 14; face++, picNum++)
{
//NSString *path = [[NSBundle mainBundle] bundlePath];
//NSString *imagePath = [path stringByAppendingPathComponent: [NSString stringWithFormat:@"/cards/card_%d.png",picNum]];
NSString *fileName = [NSString stringWithFormat:@"card_%d", picNum];
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"png"inDirectory:@"/cards"];
NSLog(@"%@", path);
UIImage *output = [UIImage imageNamed:path];
//NSLog(@"%@", output);
Card *card = [[Card alloc] initWithFaceValue:(NSInteger)face
countValue:(NSInteger)aCount
suit:(Suit)suit
cardImage:(UIImage *)output];
[cards addObject:card];
}
}
}
return self;
}
}
@end