0
有人可以向我解釋爲什麼我的變量被稱爲活動爲0時定義爲一個浮點數,但顯示正確的值時定義爲一個int?我有另一個漂浮物,用於幾乎相同的東西,但完美的作品!xcode定義變量問題
@implementation AppPrefsViewController
float age;
int activity;
...
-(void) updateAValues{
if (selectedActivityUnit == 0){
activity = 50;
NSLog(@"activity = %d",activity);
}
if (selectedActivityUnit == 1){
activity = 75;
NSLog(@"activity = %d",activity);
}
}
....
- (void)updateLabel {
if (selectedUnit == 0) {
subView.hidden = YES;
age = 1;
NSLog(@"age = %d",age);
}
if (selectedUnit == 1) {
subView.hidden = YES;
age = 2;
NSLog(@"age = %d",age);
}
if (selectedUnit == 2) {
subView.hidden = NO;
age = 3;
NSLog(@"age = %d",age);
}
}