Objective c “烦人”;“未使用的表达式结果”;警告
这是一个愚蠢的简单动画,但我一直得到这个恼人的“表达式结果未使用”警告。代码如下:Objective c “烦人”;“未使用的表达式结果”;警告,objective-c,xcode,if-statement,Objective C,Xcode,If Statement,这是一个愚蠢的简单动画,但我一直得到这个恼人的“表达式结果未使用”警告。代码如下: -(IBAction)thingOneTapped:(UIGestureRecognizer *)sender{ if ((isLevel = YES)) { thingOneEnded = YES; goingToThingOne = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@se
-(IBAction)thingOneTapped:(UIGestureRecognizer *)sender{
if ((isLevel = YES)) {
thingOneEnded = YES;
goingToThingOne = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(otherThingToOne) userInfo:nil repeats:YES];
x = 11;
y = 118;
}
else (isLevel = NO); {
[self viewDidLoad];
}
}
-(void)otherThingToOne{
if ((isLevel = YES) && (isLevelOne = YES)) {
if ((x > 0) && (y > 0)) {
otherThing.center = CGPointMake(otherThing.center.x - .5, otherThing.center.y - 5.35);
x = x - .5;
y = y - 5.35;
}
else ((x < 0) && (y < 0)); {
[self levelOneDefault];
// EVIL WARNING IS RIGHT HERE IN THE ELSE PART
}
}
-(iAction)thingOneTapped:(UIgestureRecognitor*)发送方{
如果((isLevel=YES)){
Thingonedend=是;
GoingToThingo=[NSTimer scheduledTimerWithTimeInterval:0.05目标:自选择器:@selector(otherThingToOne)用户信息:无重复:是];
x=11;
y=118;
}
else(isLevel=NO){
[自视下载];
}
}
-(无效)其他事项{
如果((isLevel=YES)&&(isLevelOne=YES)){
如果((x>0)和&(y>0)){
otherThing.center=CGPointMake(otherThing.center.x-.5,otherThing.center.y-5.35);
x=x-.5;
y=y-5.35;
}
else((x<0)和&(y<0)){
[自我水平默认];
//邪恶的警告就在这里的另一部分
}
}
要检查相等性,您需要使用==
(即两个等号),这就是为什么会出现错误的原因。此外,您的代码目前无法按预期工作
正如其他人提到的那样
不要使用if(someBool==YES)
只要使用if(someBool)
就行了。不要使用if(someBool==NO)
只要使用if(!someBool)
目前它不起作用的原因是(我认为但不是100%)if(someBool=NO)将首先将someBool
设置为NO,然后评估永远是if(NO)
的条件,该条件永远不会进入of块
我想。但我不确定,因为我还没有测试过它。您也可以这样使用,而无需检查
==
运算符,而且它会更快:-
if ((isLevel) && (isLevelOne))
要检查相等性,需要使用==(即两个等号)这就是你出错的原因。另外,你的代码目前也不会像你期望的那样工作。总是简单的事情哈哈谢谢去掉
else
行末尾的分号。另外else
后面不应该有条件子句。如果你想对条件使用else
,你必须使用else如果(条件)
。你删除了你的动画问题。现在有人能帮你吗?我发表评论时无法给出答案,现在我不能。如果(someBool==YES),你不应该做。只要做如果(someBool)
。和如果(!someBool)
而不是==NO
。顺便问一下,为什么现在它不能按预期工作?