Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/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
如何在iOS中使用大于或小于_Ios_Objective C - Fatal编程技术网

如何在iOS中使用大于或小于

如何在iOS中使用大于或小于,ios,objective-c,Ios,Objective C,如果resultText等于小丑金额(@“34”),我希望显示动画,如果resultText不是小丑金额的值,则显示单个图像。这是我的要求 -(void)clownDanceAnimation { if (counter == 1 && [resultText.text isEqualToString:clownamt]){ [self hideObjectAnimationDidStart]; NSArray *dashBoy1; dashBoy1 =

如果resultText等于小丑金额(@“34”),我希望显示动画,如果resultText不是小丑金额的值,则显示单个图像。这是我的要求

-(void)clownDanceAnimation {
if (counter == 1 && [resultText.text isEqualToString:clownamt]){
    [self hideObjectAnimationDidStart];

    NSArray *dashBoy1;
    dashBoy1 = [[NSArray alloc] initWithObjects:
                [UIImage imageNamed:@"a20001.png"],[UIImage imageNamed:@"a20002.png"],
                [UIImage imageNamed:@"a20003.png"],[UIImage imageNamed:@"a20004.png"], nil];
    stgImage1.animationImages = dashBoy1;
    stgImage1.animationDuration = 1;
    [stgImage1 startAnimating];

}
else if((counter==1 && resultText.text > clownamt)) {
    stgImage1.image = [UIImage imageNamed:@"clownDanceHide.png"];

}
}

但第一次是完美的工作和第二次无论小丑AMT是存在的(无论是34或其他值),它只显示单一的图像,而不是动画功能。每次我都会运行这个模拟器,它只运行else部分,而不是if语句

不能将字符串与
进行比较。这会让你找到你想要的东西:

NSString *string1;
NSString *string2;
if ([string1 compare:string2 options:NSNumericSearch] == NSOrderedDescending) {
    // numeric value of string1 > numeric value of string2
} else if ([string1 compare:string2 options:NSNumericSearch] == NSOrderedAscending) {
    // numeric value of string1 < numeric value of string2
} else {
    // numeric value of string1 == numeric value of string2
}
NSString*string1;
NSString*string2;
if([string1比较:string2选项:NSNumericSearch]==取消搜索){
//string1的数值>string2的数值
}else if([string1比较:string2选项:NSNumericSearch]==传感器解除搜索){
//string1的数值

首先确保两个字符串都不是
nil
。以下是获取更多信息的示例。

您是否在应用程序中的任何位置更改计数器值?第二次检查计数器值?检查计数器值您需要在执行第二次时检查计数器值和计数器值>只需使用断点并在consoleconvert字符串中将其显示为整数值,然后比较您的条件是否正确。。。与[resultText.text intValue]类似,这将使字符串变成整数,然后您的条件将起作用。:)首先,我只使用整数,即@“34”,这是满足的条件。但如何放弃其他功能。(resultText.text>@“34”)这是否正确。。。