我写:
NSNumber *aNumber = [NSNumber numberWithInt: 0];
NSNumber *bNumber = [NSNumber numberWithInt: [aNumber intValue] + 5];
为什么我会收到一条警告说 aNumber 在 bNumber 行上未声明?
编辑:
这些代码:
NSNumber *aNumber = [NSNumber numberWithInt: 0];
NSNumber *bNumber = [NSNumber numberWithInt: [aNumber intValue] + 5];
return [NSString stringWithFormat:@"%ld", (long)bNumber];
在方法中使用:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
在 aNumber 行,我收到投诉“预期表达式”,在 bNumber 行,我收到“Unknown receiver 'aNumber';您的意思是 NSNumber”吗?为什么呢?
编辑2:
switch (component){
case 0:
NSNumber *aNumber = [NSNumber numberWithInt: 0];
NSNumber *bNumber = [NSNumber numberWithInt: [aNumber intValue] + 5];
return [NSString stringWithFormat:@"%ld", (long)bNumber];
break;
case 1:
//....
break;
case 2:
//....
break;
}
我怀疑我不能在 switch 语句中声明任何内容?