[英]Conflicting parameter types in implementation of NSUInteger vs NSInteger
I have a problem with an error about conflicting parameter types in implementation of NSUInteger vs NSInteger. 我在NSUInteger与NSInteger的实现中存在关于参数类型冲突的错误的问题。
I have seen a lot of similar issues and it seems that the most frequent ones happen while defining the pointer with the * character. 我已经看到很多类似的问题,而且似乎最常见的问题是在用*字符定义指针时发生的。
Integer is a primitive type and I'm not using pointers at all, so where is the problem ? 整数是原始类型,我根本不使用指针,所以问题出在哪里?
- (void) guessNumber: (NSInteger)number withRange:(NSInteger)range{
dispatch_queue_t queue = dispatch_queue_create("com.alex.guessnumber.queue", DISPATCH_QUEUE_SERIAL);
dispatch_async(queue, ^{
double startTime = CFAbsoluteTimeGetCurrent();
NSInteger randomNumber;
NSInteger range;
while (randomNumber != number) {
randomNumber = arc4random_uniform(range);
}
NSLog(@"Student %@ guessed number %d in %f", self.name, randomNumber, CFAbsoluteTimeGetCurrent() - startTime);
});
}
arc4random_uniform返回uint32_t,其值从0到2 ^ 32-1。您尝试将其存储在NSInteger中,在32位系统上,该值的范围是-2 ^ 31至+ 2 ^ 31-1。这是行不通的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.