在树形教程之后,我在XCode中看到这个流行的Object-C警告消息。目标c隐式转换失去整数精度'NSUInteger'
我的按钮功能
- (IBAction)buttonPressed:(UIButton *)sender {
NSUInteger index = arc4random_uniform(predictionArray.count);
self.predictionLabel.text = [predictionArray objectAtIndex:index];
}
我看到它在NSUInteger行,我已经很少几个类似stackoverflows的,他们似乎谈论32位VS 64位数字和类型转换,但不知道如何在这里做?
我predictionArray
- (void)viewDidLoad
{
[super viewDidLoad];
predictionArray = [[NSArray alloc] initWithObjects:
@"It is certain", @"It is decidely so", @"All signs say YES", @"The stars are not aligned",
@"My reply is no",
@"It is doubtful",
@"Better not tell you now",
@"Concentrate and ask again",
@"Unable to answer now", nil];
// Do any additional setup after loading the view, typically from a nib.
}
嗯,我只是试过这个,但仍然是相同的警告。那么,我将NSUInteger铸造成什么? “(NSUInteger)”是什么意思。或者更重要的是,它警告我的是什么? –
@LeonGaban:我把剧组放在了错误的地方。 –
谢谢!仍然试图理解这一点,所以'NSUInteger'总是一个32位的int?我试图将它转换为64位并得到相同的错误。那些东西对我来说是新鲜的,从来没有碰到过它。 –