-(IBAction)someMethod:(UIStepper *)sender{
int x=sender.value; //This is an integer from 0-8;
NSLog(@"%f",sender.value);
NSArray *rpmValues = [[NSArray alloc]initWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i", nil];
if (x<=[rpmValues count]) {
myLabel.text = [rpmValues objectAtIndex:x];
}
NSLog(@"%i",[rpmValues count]);
}
以上是我的代码,我想做的是通过改变 UIStepper 来改变 UILabel 的显示。这是非常直接的。但是当我改变按下步进值时,它会崩溃:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** - [__NSArrayM objectAtIndex:]: index 1 beyond bounds for empty array'
*** First throw call stack:
[rpmValue count] 是 9。我真的很困惑。谁能帮我?