Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6245013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:25:53+00:00 2026-05-24T12:25:53+00:00

I want to group the numbers entered into my amount field, using . as

  • 0

I want to group the numbers entered into my amount field, using “.” as the grouping seperator, like 100.000

I implemented shouldChangeCharactersInRange method of my view controller so that only numbers and one comma is allowed for the decimal part, which can be only 2 digits.

Now I want to put the grouping seperator as the user enters the digits, in real time. When I think of the implementation, I am confused about things like the user deleting the digits or things like the user placing the cursor at the beginning and typing 0 in the front of the entered number, and so…

What would be the cleanest implementation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:25:54+00:00Added an answer on May 24, 2026 at 12:25 pm

    OK, here is how:

    First, you implement a UITextField category.
    Then you say to yourself:

    [self addTarget:self action:@selector(formatTextAsNumber) forControlEvents:UIControlEventEditingChanged];

    And here is the formatTextAsNumber method that does the charm:

    - (void)formatTextAsNumber {
    
        [self removeTarget:self action:@selector(formatTextAsNumber) forControlEvents:UIControlEventEditingChanged];
    
        if ([self.text length] > 0) {
            NSString *currentText = [NSString stringWithString:self.text];
    
            currentText = [currentText stringByReplacingOccurrencesOfString:kGroupingSeperator withString:@""];
            currentText = [currentText stringByReplacingOccurrencesOfString:@"," withString:@"."];
    
            NSString *suffix = [currentText substringFromIndex:[currentText length] - 1];
    
            NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
            NSLocale *trLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"tr_TR"] autorelease];
            [formatter setLocale:trLocale];
    
            NSNumber *number = [NSNumber numberWithDouble:[currentText doubleValue]];
            [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
            [formatter setGroupingSeparator:@"."];
    
            NSString *finalText = [formatter stringFromNumber:number];
    
            if ([suffix isEqualToString:@"."]) {
                finalText = [finalText stringByAppendingString:@","];
            }
    
            self.text = finalText;
            [formatter release];
        }
    
        [self addTarget:self action:@selector(formatTextAsNumber) forControlEvents:UIControlEventEditingChanged];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I using group by with union in T-SQL? I want to group
I have this input string(oid) : 1.2.3.4.5.66.77.88.99.10.52 I want group each number into 3
I want to group results of query by the item id and count number
model.py: class Tribes(Group): members = models.ManyToManyField(User, related_name='tribes', verbose_name=_('members')) i want to store a number
I have this scenario. I want group on Country and Category. A store can
I want to group an sql statement by a column alias. In essense, I
I want to group every date that it is in the database and get
I want to group the common methods in one file and use it. For
I want to group by on dict key >>> x [{'a': 10, 'b': 90},
I want to group items only when there are more than 2 rwos matching

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.