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 8719065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:42:02+00:00 2026-06-13T06:42:02+00:00

In my application i am trying to format phone numbers based on the user

  • 0

In my application i am trying to format phone numbers based on the user locale. The issue i am facing is as follows:

Code in the Viewcontroller.m:

   NSString *contact = [_phone convertContact:myNumber withLocale:typeN];
   NSLog(@"Phone number %@ and number = %@",contact,myNumber);

   //Console output 2012-07-23 15:40:16.994 InternProj[7585:f803] value of en and      23443235434

Code in the PhoneNumber.m:

   - (NSString *) convertContact:(NSNumber *)aNumber withLocale:(NSString *)locale{

  NSString *localeString = locale ;
  NSLog(@"value of %@ and %@",localeString , aNumber);
  NSString *tempStr = [[NSString alloc] initWithString:@""];
  NSRange range;
  range.length = 3;
  range.location = 3;
   //Returns the phone number 2032225200 as 1(203)222-5200
  if([localeString compare:@"en"] == NSOrderedSame) {
    NSLog(@"Inside en");
    NSString *areaCode = [[aNumber stringValue] substringToIndex:3];
    NSString *phone1 = [[aNumber stringValue] substringWithRange:range];
    NSString *phone2 = [[aNumber stringValue] substringFromIndex:6];

    tempStr = [NSString stringWithFormat:@"1(%@)%@-%@", areaCode, phone1, phone2];
    NSLog(@"Value tempStr = %@",tempStr);
}
else {
    tempStr = [[aNumber stringValue] substringToIndex:3];
}


  return tempStr;
}

I am getting a null as a return value from convertContact method. I tried all the permutations but I am not getting whr im going wrong. Also if anyone has Iphone locale based phone number formatting info please share.

  • 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-06-13T06:42:03+00:00Added an answer on June 13, 2026 at 6:42 am

    First of all iOS does not support for Phone number formatting. The developer has to write his own plugins. Also do mention what is typeN variable that you are passing in the method. Also check whether aNumber is not null. I am pretty sure that the number that you are passing in the method is the cause for null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying different format for a price value in an application (ASP.NET MVC 4),
I'm trying to format an excel column that I created in a .net application.
I am trying to export my application to another process management format/system (specifically, upstart
When I'm trying to open my javafx application in jnlp format I'm getting the
I'am trying to rewrite zend framework configuration file from application.ini to application.yml format and
Trying to code a Windows Phone silverlight app, and I'm trying to copy a
I'm trying to format some numbers in a column of a DataGrid. I'm getting
I'm trying to develop a way of switching Windows Phone 7 application style depending
this is related to my previous question. I'm trying to build Phone application from
I get this error when trying to have a WPF application try to format

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.