Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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 指针问题与整数问题的比较_Iphone_Objective C_Ios - Fatal编程技术网

Iphone 指针问题与整数问题的比较

Iphone 指针问题与整数问题的比较,iphone,objective-c,ios,Iphone,Objective C,Ios,我有一个条件语句,需要语法方面的帮助: if (mySegment.selectedSegmentIndex == 0 && [[[dict objectForKey:[keys objectAtIndex:row]] objectAtIndex:0] == 8 ) { NSLog(@"test"); } 我正在比较指针和整数问题警告。我需要一个基于段值选择的条件,然后将其与dictionary对象返回的值进行比较 感谢您的帮助。NSDictionary对象只能包含NSNumb

我有一个条件语句,需要语法方面的帮助:

if (mySegment.selectedSegmentIndex == 0 && [[[dict objectForKey:[keys objectAtIndex:row]] objectAtIndex:0] == 8 ) {
NSLog(@"test");
}
我正在比较指针和整数问题警告。我需要一个基于段值选择的条件,然后将其与dictionary对象返回的值进行比较


感谢您的帮助。

NSDictionary对象只能包含NSNumber实例,不能包含integer等基本标量类型。这就是你得到警告的原因

试试这句话:

if (mySegment.selectedSegmentIndex == 0 && [[[[dict objectForKey:[keys objectAtIndex:row]] objectAtIndex:0] integerValue] == 8 ) {
...
}

请注意,我在从数组返回的对象上添加了对integerValue的调用。

NSDictionary对象只能包含NSNumber实例,不能包含integer之类的基元标量类型。这就是你得到警告的原因

试试这句话:

if (mySegment.selectedSegmentIndex == 0 && [[[[dict objectForKey:[keys objectAtIndex:row]] objectAtIndex:0] integerValue] == 8 ) {
...
}
请注意,我在从数组返回的对象上添加了对integerValue的调用。

[[dict objectForKey:[keys objectAtIndex:row]]objectAtIndex:0]返回一个对象,该对象必须在与整数8进行比较之前类型转换为int

int[[[dict objectForKey:[keys objectAtIndex:row]]objectAtIndex:0]==8应该可以帮到你。

[[dict objectForKey:[keys objectAtIndex:row]]objectAtIndex:0]返回一个对象,该对象在与整数8进行比较之前必须被类型转换为int

int[[[dict objectForKey:[keys objectAtIndex:row]]objectAtIndex:0]==8应该可以帮你解决这个问题。

将dict值转换为整数,然后进行比较

试试这个:

if (mySegment.selectedSegmentIndex == 0 && [[[dict objectForKey:[keys objectAtIndex:row]] objectAtIndex:0]intValue] == 8 ) {
NSLog(@"test");
}
将dict值转换为整数,然后比较

试试这个:

if (mySegment.selectedSegmentIndex == 0 && [[[dict objectForKey:[keys objectAtIndex:row]] objectAtIndex:0]intValue] == 8 ) {
NSLog(@"test");
}

哦,太好了,我完全忘记了方法调用,跳转到c语法。我在想我是应该删除我的答案还是让它成为c语法。不过,我想我完全忘记了方法调用,跳转到c语法。我在想我是应该删除我的答案还是让它成为c语法。不过+1对你来说非常有效!谢谢。我不知道该把答案放在哪里intValue工作得很好!谢谢。我不知道把intValue放在哪里