Take the 2-minute tour ×

I'm trying to access an UIImage instance variable and display it in UIImageView. When I try to NSLog the path I get null. I can manually display a pic through the IB, but I want to do this strictly through code

#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 *fileName = [NSString stringWithFormat:@"card_%d", picNum];
                NSString *path = [[NSBundle mainBundle] pathForResource:fileName         

                NSLog(@"%@", path);                          //outputs correctly

                UIImage *output = [UIImage imageNamed:path];

                NSLog(@"%@", output);                        //outputs null

                Card *card = [[Card alloc] initWithFaceValue:(NSInteger)face
                                                cardImage:(UIImage *)output];

                [cards addObject:card];

    return self;

I've added a link to show where the pics are found


share|improve this question
any suggestions –  blitzeus Dec 28 '12 at 20:46

1 Answer 1

You don't have to include all the path to the image, if you just put the name, Xcode will automatically look for it.

share|improve this answer

Your Answer


