UIImage インスタンス変数にアクセスして、UIImageView に表示しようとしています。パスを NSLog しようとすると、null になります。IB を使用して写真を手動で表示できますが、コードを使用してこれを厳密に行いたい
#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
ofType:@"png"inDirectory:@"/cards"];
NSLog(@"%@", path); //outputs correctly
UIImage *output = [UIImage imageNamed:path];
NSLog(@"%@", output); //outputs null
Card *card = [[Card alloc] initWithFaceValue:(NSInteger)face
countValue:(NSInteger)aCount
suit:(Suit)suit
cardImage:(UIImage *)output];
[cards addObject:card];
}
}
}
return self;
}
写真が見つかった場所を示すリンクを追加しました