Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

int3rc3pt0r

macrumors newbie
Original poster
Feb 9, 2010
9
0
Hey Guys ,

I am a N00b here .

I print my currency like this :
Code:
-(IBAction)buttonPressed1:(id)sender
    {
    double currency = [Amount1.text doubleValue] + [Amount2.text doubleValue]; 
    SumCurrency.text = [NSString stringWithFormat:@"%0.0f", answer];
    }

I just simply want to use NSSNumberFormatter to print the SumCurrency.text in US Currency format ..( A comma sign after every 3 digits , nothing more than that )
Having a lot of trouble with it ..Please help

If this can be done without NSNumberFormatter also will help a lot.

Is my problem same as this link :
http://groups.jonzu.com/z_apple_using-a-nsnumberformatter-with-a-uitextfield.html


Thanks in Advance .

Regards , N00b
 

int3rc3pt0r

macrumors newbie
Original poster
Feb 9, 2010
9
0
I got the answer

I got the answer .. But for anyone's future refernce

Code:
      -(IBAction)buttonPressed1:(id)sender
         {
        double currency = [Amount1.text doubleValue] + [Amount2.text doubleValue]; 
    NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
    [numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
    NSString *numberAsString = [numberFormatter stringFromNumber:[NSNumber numberWithInt:currency]];
    SumCurrency.text = [NSString stringWithFormat:@"Converted:%@",numberAsString];	
        }
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.