Advertisement
Don_Mag

string format example

Mar 4th, 2021
2,328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     NSNumber *quantity = [NSNumber numberWithDouble:1];
  2.     NSNumber *price_vat = [NSNumber numberWithDouble:0.76];
  3.    
  4.     double totalPrice = 293;
  5.    
  6.     totalPrice = totalPrice + [quantity doubleValue] * [price_vat doubleValue];
  7.    
  8.     NSString *s = [NSString stringWithFormat:@"%0.2f", totalPrice];
  9.    
  10.     NSLog(@"total: %@", s);
  11.    
  12.     // in case we're testing without the IBOutlet connected,
  13.     //  don't try to set its .text
  14.     if (nil != self.priceLabel) {
  15.         self.priceLabel.text = s;
  16.     }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement