I think this is BRAZILIAN REAL CURRENCY Format. You have to call this method with your price in float value, and this method returns your string into your format. Like if we pass 123456789
, then it will return 123,456,789.00
.
//Convert Price to Your Price Format
+(NSString*)convertFormat:(float)value{
NSString * convertedString = [NSString stringWithFormat:@"%.2f", value];
NSString * leftPart;
NSString * rightPart;
if (([convertedString rangeOfString:@"."].location != NSNotFound)) {
rightPart = [[convertedString componentsSeparatedByString:@"."] objectAtIndex:1];
leftPart = [[convertedString componentsSeparatedByString:@"."] objectAtIndex:0];
}
//NSLog(@"%d",[leftPart length]);
NSMutableString *mu = [NSMutableString stringWithString:leftPart];
if ([mu length] > 3) {
[mu insertString:@"." atIndex:[mu length] - 3];
//NSLog(@"String is %@ and length is %d", mu, [mu length]);
}
for (int i=7; i<[mu length]; i=i+4) {
[mu insertString:@"." atIndex:[mu length] - i];
//NSLog(@"%d",mu.length);
}
convertedString = [[mu stringByAppendingString:@","] stringByAppendingString:rightPart];
return convertedString;
}
For more details, refer this blog.
Hope, this is what you're looking for. Any concern get back to me.