Jason
Jason

Reputation: 650

Formatting UITextField not working?

Im trying to format my textfield for float values. Example: 0.00" for some reason the code below works fine for other texfields, but not this one. Whats the deal? for my variables, i'm codeing them like this:

double var1 = [[myOtherTextField text] doubleValue];
double var2 ext...(same formatting as above, different textfield of course);
double var3 ext...(same formatting as above);

[myTextField setText:[NSString stringWithFormat:@"%0.0f''", (var1 + var2 - var3)]];

The other two textfields are formatted the same way and are showing fine...why isn't this one? Thanks in advanced.

Upvotes: 0

Views: 118

Answers (1)

thomashw
thomashw

Reputation: 956

Try this.

double var1 = [[myOtherTextField text] doubleValue];
double var2 ext...(same formatting as above, different textfield of course);
double var3 ext...(same formatting as above);

[myTextField setText:[NSString stringWithFormat:@"%1.2f\"", (var1 + var2 - var3)]];

Upvotes: 1

Related Questions