Hai poco controllo sulla formattazione se usi semplicemente stringValue
per il tuo NSNumber
. Invece dovresti assicurarti di convertirsi nel tipo di dati primitivi e formato corretti come desiderato:
kgLabel.text = [NSString stringWithFormat:@"%.0f kg", number.floatValue];
// --> "23 kg"
kgLabel.text = [NSString stringWithFormat:@"%.2f kg", number.floatValue];
// --> "23.43 kg"