Don_Mag

string format example

Mar 4th, 2021
717
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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×