Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 消息表达式中的参数是未初始化的值(imageFile)_Iphone_Objective C_Cocos2d Iphone - Fatal编程技术网

Iphone 消息表达式中的参数是未初始化的值(imageFile)

Iphone 消息表达式中的参数是未初始化的值(imageFile),iphone,objective-c,cocos2d-iphone,Iphone,Objective C,Cocos2d Iphone,我以前查过好几次,并尝试了答案所说的,但当我运行Xcode的分析器时,它说的是相同的“消息表达式中的参数是未初始化的值”。 这是switch语句: ` } `如果调用了default语句,则imageFile为nil,spriteWithFile不知道该怎么办。确保处理由default传递的nil语句,或者将imagefile设置为默认情况下可用的内容。“default:nil;break;”是多余的语句。它什么也不做。它与“default:break”相同,或者只是完全删除默认块。我读到它应该

我以前查过好几次,并尝试了答案所说的,但当我运行Xcode的分析器时,它说的是相同的“消息表达式中的参数是未初始化的值”。 这是switch语句:

`

}


`

如果调用了
default
语句,则
imageFile
nil
spriteWithFile
不知道该怎么办。确保处理由
default
传递的
nil
语句,或者将
imagefile
设置为默认情况下可用的内容。

“default:nil;break;”是多余的语句。它什么也不做。它与“default:break”相同,或者只是完全删除默认块。我读到它应该对这些类型的线程中的另一种有帮助。这只是我在另一个线程中读到它后尝试的一个实验。默认值永远不会被调用。如果您注释掉开关的大小写,然后运行
Coins*c=[Coins spriteWithFile:@“coin6.png”]无(没有硬币显示)。
Coins*c=[Coins spriteWithFile:imageFile]也是如此问题所在行?还是更早?
NSString *imageFile;
switch (randomCoinType) {


    case 1:



        imageFile = @"coin.1.png";
        break;

    case 2:

        imageFile = @"coin.2.png";
        break;

    case 3:
    case 4:
        imageFile = @"coin.3.png";
        break;

    case 5:
    case 6:
    case 7:
    case 8:
        imageFile = @"coin.4.png";
        break;

    case 9:
        imageFile = @"coin.5.png";
        break;

    case 0:
        imageFile = @"coin.6.png";
        break;

    default: 

        break;


      }


//argument in message is uninitialized here!
Coins *c = [Coins spriteWithFile:imageFile];




c.type = type;
c.position = position;
c.velocity = ccp(0,0);
[coins addObject:c];
[self addChild:c z:2];