1
finab OP count 方法返回的是 NSUInteger ,我的 index 是 NSInteger
这两种数据类型比较会存在问题吧 |
2
fogisland 2015-11-30 11:52:54 +08:00
@finab 这是 C 语言的范畴了, int 会被强转为 uint ,因此 -1 > _group.count ;
直接写 -1 > 2 返回 false, 是因为常数的默认类型都是 int , 不会发生类型转换 |
3
loveuqian 2015-11-30 11:55:33 +08:00 via iPhone
为啥你自定义类 view 是小写字母开头
|
4
finab OP @fogisland 我比较好奇的是
int 与 uint 比较,会把 int 转成 uint, 而不是将 uint 转成 int - - NSLog(@"%u", -1); // 输出 4294967295 |
6
fogisland 2015-11-30 12:59:29 +08:00
@finab
给你个链接看看: https://www.securecoding.cert.org/confluence/display/cplusplus/INT02-CPP.+Understand+integer+conversion+rules "If the operand that has unsigned integer type has rank greater than or equal to the rank of the type of the other operand, the operand with signed integer type is converted to the type of the operand with unsigned integer type." |
8
wizardforcel 2015-11-30 16:12:22 +08:00 via Android
|
9
surfire91 2015-11-30 18:28:21 +08:00
@wizardforcel 这还不是溢出?
|
10
wezzard 2015-11-30 20:00:44 +08:00
lou zhu zai diao yu.
|