在树屋教程之后,我在 XCode 中看到了这个流行的 Object-C 警告消息。
我的按钮功能
- (IBAction)buttonPressed:(UIButton *)sender {
NSUInteger index = arc4random_uniform(predictionArray.count);
self.predictionLabel.text = [predictionArray objectAtIndex:index];
}
我在 NSUInteger 线上看到它,我有几个类似的 stackoverflow,他们似乎在谈论 32 位与 64 位数字和类型转换,但不知道如何在这里做到这一点?
我的预测数组
- (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.
}