我选择了一种采用标签值并更改比率标签的方法:
- (void)CalculateRatio {
int temp;
int PRBCs = [self.labelPRBCs.text integerValue];
int FFP = [self.labelFFP.text integerValue];
int u = PRBCs;
int v = FFP;
while (v != 0) {
temp = u % v;
u = v;
v = temp;
}
int PRBCratio = PRBCs / u;
int FFPratio = FFP / u;
double Plateletratio = [self.labelPlatelets.text doubleValue] / u;
double Cryoratio = [self.labelCryo.text doubleValue] / u;
NSString *returnValue = [NSString stringWithFormat:@"%d : %d : %.1lf : %.1lf", PRBCratio, FFPratio, Plateletratio, Cryoratio];
self.calculatedRatio.text = returnValue;
}
如果您能看到一些语法错误以及改进方法,我会很高兴听到它们。干杯。