Saturday, July 16, 2016

Add INR ahead of price value Eg. INR. 1,000


 _lblPriceValue.text = [_ModelController.price changePriceformatAndAddUnit];

- (NSString *)changePriceformatAndAddUnit {
    return [NSString stringWithFormat:@“INR. %@", [self changePriceformat]];
}


- (NSString *)changePriceformat {
    int count = 0;
    long long int a = self.longLongValue;
    while (a != 0) {
        count++;
        a /= 10;
    }
    
    NSMutableString *string = [NSMutableString stringWithString:self];
    NSMutableString *newstring = [NSMutableString string];
    while (count > 3) {
        count -= 3;
        NSRange rang = NSMakeRange(string.length - 3, 3);
        NSString *str = [string substringWithRange:rang];
        [newstring insertString:str atIndex:0];
        [newstring insertString:@"," atIndex:0];
        [string deleteCharactersInRange:rang];
    }
    [newstring insertString:string atIndex:0];
    
    return newstring;

}

No comments:

Post a Comment