项目中的图像不添加到数组 - 不知道为什么

时间:2010-05-26 09:32:24

标签: iphone-sdk-3.0 image nsmutablearray

我需要一组图像。每组有16个图像。一组叫做0.png到15.png,另一组是a0.png到a15.png。

在我的应用中,它会根据变量加载每个变量(通过记录,我证明它有效)

这是代码

[MemoryManager sharedMemoryManager];

NSLog(@"THEME: %@", [MemoryManager sharedMemoryManager].themeName);
    imageArray = [[NSMutableArray alloc] init];
if([MemoryManager sharedMemoryManager].themeName == @"hand"){
    NSLog(@"Here 2");


[imageArray addObject:[UIImage imageNamed:@"0.png"]]; //
[imageArray addObject:[UIImage imageNamed:@"1.png"]];//1
[imageArray addObject:[UIImage imageNamed:@"2.png"]];//2
[imageArray addObject:[UIImage imageNamed:@"3.png"]];//3
[imageArray addObject:[UIImage imageNamed:@"4.png"]];//4
[imageArray addObject:[UIImage imageNamed:@"5.png"]];//5
[imageArray addObject:[UIImage imageNamed:@"6.png"]];//6
[imageArray addObject:[UIImage imageNamed:@"7.png"]];//7
[imageArray addObject:[UIImage imageNamed:@"8.png"]];//8
[imageArray addObject:[UIImage imageNamed:@"9.png"]];//9
[imageArray addObject:[UIImage imageNamed:@"10.png"]];//10
[imageArray addObject:[UIImage imageNamed:@"11.png"]];//11
[imageArray addObject:[UIImage imageNamed:@"12.png"]];//12
[imageArray addObject:[UIImage imageNamed:@"13.png"]];//13
[imageArray addObject:[UIImage imageNamed:@"14.png"]];//14
[imageArray addObject:[UIImage imageNamed:@"15.png"]];//15

}
if([MemoryManager sharedMemoryManager].themeName == @"letters"){
    NSLog(@"Here 3");


    //[imageArray removeAllObjects];
    [imageArray addObject:[UIImage imageNamed:@"a0.png"]]; //
    [imageArray addObject:[UIImage imageNamed:@"a1.png"]];//1
    [imageArray addObject:[UIImage imageNamed:@"a2.png"]];//2
    [imageArray addObject:[UIImage imageNamed:@"a3.png"]];//3
    [imageArray addObject:[UIImage imageNamed:@"a4.png"]];//4
    [imageArray addObject:[UIImage imageNamed:@"a5.png"]];//5
    [imageArray addObject:[UIImage imageNamed:@"a6.png"]];//6
    [imageArray addObject:[UIImage imageNamed:@"a7.png"]];//7
    [imageArray addObject:[UIImage imageNamed:@"a8.png"]];//8
    [imageArray addObject:[UIImage imageNamed:@"a9.png"]];//9
    [imageArray addObject:[UIImage imageNamed:@"a10.png"]];//10
    [imageArray addObject:[UIImage imageNamed:@"a11.png"]];//11
    [imageArray addObject:[UIImage imageNamed:@"a12.png"]];//12
    [imageArray addObject:[UIImage imageNamed:@"a13.png"]];//13
    [imageArray addObject:[UIImage imageNamed:@"a14.png"]];//14
    [imageArray addObject:[UIImage imageNamed:@"a15.png"]];//15


    NSLog(@"Here 4");
}

日志说

2010-05-26 21:30:57.092 Memory[22155:207] Here 1
2010-05-26 21:30:57.093 Memory[22155:207] THEME: letters
2010-05-26 21:30:57.095 Memory[22155:207] Here 3
2010-05-26 21:30:57.109 Memory[22155:207] Here 4

图像与.xproj文件位于同一文件夹中。他们只是不工作。 有任何想法吗? 干杯

1 个答案:

答案 0 :(得分:0)

我发现了。长话短说,我忘记将if语句添加到游戏过程中发生的代码的另一部分 - 因此看起来它没有正确加载图像,但代码工作得很好。

有一天啊.. xcode能够早点告诉你你做错了什么!我希望..